javascript - Mousemove events are not triggered when I drag the scroll bar with the mouse -
i need detect mouse movement on drag of websites scroll bar, allows me detect user inactivity.
when scroll bar being dragged mouse move event not firing.
not working in ie11 , chrome, i'm seeing mousemove events fire in firefox 32, have not tested other browsers.
sample code:
html
<div class="parent" style="background-color:black;width:100px;height:500px;overflow:scroll;"> <div class="child" style="background-color:blue;width:100px;height:1000px"></div> </div>
javascript:
var lastmove; $(window).mousemove(function (e) { lastmove = new date(); $(".child").css("background-color", "red"); lasttimemousemoved = new date().gettime(); var t=settimeout(function(){ var currenttime = new date().gettime(); if(currenttime - lasttimemousemoved > 10){ $(".child").css("background-color", "blue"); } },10); });
js fiddle: https://jsfiddle.net/btdxha8k/
binding scroll event solution have wondering if there more clean solution need bind 100+ div's not need scrolling events looks redundant, dirty , don't using hacks in code.
cheers ;)
mouse move event triggered when move mouse within screen. issue here scrollbar not inner side of screen mouse move event captured shoul add scroll event same function
Comments
Post a Comment