如何使用事件监听器检测mousemove
何时结束?
document.AddEventListener('mousemove', startInteractionTimer, false);
function startInteractionTimer(){
clearInterval(touchInterval);
touchInterval = setInterval(noAction, 6000);
}
我希望在鼠标移动结束后立即开始函数
startInteractionTimer
,并且我想要捕获它。在上面的代码示例中,如果鼠标移动,则会启动。
谢谢
编辑:好的,我自己回答了我的问题,上面的脚本 - ^ 就可以了。
mousemove
事件没有停止事件,那么如何检测呢?只有在与mousedown
和mouseup
结合使用时才能检测到,例如拖动操作) - t.niese6000
毫秒内不停止移动,就不会调用noAction
。如果鼠标在6秒内没有移动,则会调用noAction
。 - t.niese