I have a function called with mouse-wheel event that launch an animation which can be misinterpreted if it is played many times before the animation is done. I tried with setTimeout or setInterval but both keep in memory the number of events (and repeat my animation badly). The goal is to be able to call my function immediately and wait for like 2s before I can fire the event again.
It will be add on this code: JSFiddle
var scroll = 0;
$('body').bind('mousewheel', function(e) {
if (scroll < 8) scroll++;
else {
scroll = 0;
// My code...
}
});