开发者

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)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜