views:

59

answers:

1

I need to find a way to randomly scroll horizontally and vertically, plus or minus a set number of pixels per second in each dimension, when the mouse has been idle for a set amount of time. Any ideas on how to achieve this?

Thanks in advance,

Robert

+1  A: 

You can add a mousemove event listener, and each time the mouse moves, you could use setTimeout to start a counter. After the counter has finished you could safely say that the mouse hasn't been moved. Note that you would need to keep resetting the counter if the user continues moving it (ie. with clearTimeout)

Jani Hartikainen