I'm using the jquery-mousewheel plugin to trigger a function.
When I call moveit I detach the listener and wait until the animation is completed, then I re-attach the listener.
The problem is that when I re-attach it, the mousewheel plugin is still listening to the inertia of some mouses/trackpads, and call moveit repeatedly.
I guess debouncing or throttling the function call are not good solutions in my specific case, because the inertia is still there, and I also want the listener to be attached immediately for other possible moveit calls.
Is there a way to "kill the inertia" by completely resetting the mousewheel event, instead of only detaching 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();
});