I am trying to disable mousewheel on mousewheel event and only enable it after the action is completed.
$(window).on('DOMMouseScroll mousewheel', function (event) {
//disable mousewhell until the following animation is complete
$('.box').animate({
margin: div_offset+'px 0 0 0'
}, 500);
//enable mousewhell
return false;
});
I would also like the code to ignore every scroll after the first one, until the animation is complete. In this particular case, I want the animation to complete only once, even if the user scrolls for more than one tick on mouse wheel. Basically in this case, I want the mouse wheel to be disabled for 500 milliseconds after a single mouse scroll "tick", and not register the remaining "ticks" ever (if the user scrolls for 10 ticks during these 500 milliseconds, I only want one animation, while the rest are ignored). After 500 milliseconds, I want the mousewheel to be enabled once again.
I thank you in advance.