javascript - Disable Predictive Scrolling - Mousewheel (OnScroll) Event fires too often (Touchpad) - JS -
i executing javascript onscroll. code works great normal computer mouse, when use notebooks touchpad, encounter following situation:
- my mouse fires (about 1 8) mousewheel events while finger moving wheel.
- my touchpad fires lot more (~60) mousewheel events while 2 fingers touching pad and continues fire after fingers in air again.
i know behavior mobile touch devices. feature called "predictive touch" - scrolling continues if finger movement had enough acceleration before lifting up.
i think touchpad drivers setting "smooth scrolling" behavior.
to debug case, have used following code:
/* handle mouse-wheel scrolling */ var lastchange = +new date(); $(window).bind('mousewheel', function(e){ console.log("mw"); if(+new date() - lastchange > 1000){ console.log("mw allowed"); if(e.originalevent.wheeldelta > 0) {/*go previous*/} else{ /*go next*/} lastchange = +new date(); } return false;});
this simple code "allows" mouse-scrolling-event every second.
if make fast touchpad-scroll, mousewheel event fired ~300 times. one-second-condition letting 3 events happen. fingers on touchpad far less second.
with test, discovered mousewheel events still fired (almost continuously 3 seconds), when fingers off touchpad.
is there javascript function or workaround / trick / hack avoid behavior?
something "ontouchend" event touchpads, maybe?
to achieve this, you'd have distinguish between mouse scroll events , touchpad events, not (yet) possible using javascript. asked in question how capture touch pad input.
pointer events in state of editor's draft , not yet supported browser. see touch events docs on mdn.
Comments
Post a Comment