How to detect when mouse has stopped
It's really simple: when the mouse is moved, set a timeout for XXX milliseconds in the future. Also, clear any past timeouts to reset the time. Like this in the mousemove listener
clearTimeout(timer);
timer=setTimeout(mouseStopped,300);
See this JSFiddle.