开发者

Determine if mouse is still in javascript/jQuery?

开发者 https://www.devze.com 2022-12-23 10:24 出处:网络
I\'d like to be able to us开发者_JS百科e jQuery to trigger an event if the mouse has been stationary for a certain amount of time.

I'd like to be able to us开发者_JS百科e jQuery to trigger an event if the mouse has been stationary for a certain amount of time.

Any ideas? I'm not even sure where to start!


There's the idleTimer plugin which could be used for this purpose. And here's a nice demo of the plugin in action.


Hook up a mousemove() handler on the document and set a timeout. When timeout elapses, do your thing. Whenever the mouse moves again, cancel the timeout so it will fire relative to the last mouse movement.

This is a combination of jQuery and JavaScript.


jquery 1.4 offers a new method delay() for that

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号