Automatically scroll when mouse is idle
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
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
)
精彩评论