I am using jquery-mousewheel plugin to run a function.
When I call moveit, I disconnect the listener and wait until the animation is complete, then I reconnect the listener.
The problem is that when I reattach it, the mousewheel plugin still listens to the inertia of some mice / trackpads and repeatedly calls moveit.
I think that debouncing or throttling function calls are not good solutions in my particular case, because inertia still exists, and I also want the listener to be immediately connected to other possible moveit calls.
Is there a way to "kill inertia" by completely resetting the mouse event, instead of separating it?
$(document).ready(function () { var tween; var slide = $('#slide'); function bodyListen () { $('body').on('mousewheel.bodyscroll', function (e, delta, deltaX, deltaY) { e.preventDefault(); $('body').off('mousewheel.bodyscroll'); moveit(); }); } function moveit () { tween = TweenMax.to(slide, 0.8, { marginLeft: 300, onComplete: bodyListen }); } bodyListen(); });
javascript jquery mousewheel mouseevent
Luke
source share