JP.
JP.

Reputation: 5594

Determine if mouse is still in javascript/jQuery?

I'd like to be able to use 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!

Upvotes: 1

Views: 908

Answers (3)

Luca Rocchi
Luca Rocchi

Reputation: 6464

jquery 1.4 offers a new method delay() for that

Upvotes: 0

Darin Dimitrov
Darin Dimitrov

Reputation: 1038710

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

Upvotes: 1

John K
John K

Reputation: 28869

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.

Upvotes: 1

Related Questions