For performance reasons I want to deactivate a hover effect during scrolling and activate it again on scroll end. I'm using a class to activate and deactivate the hover.
Right now I have this
$(window).scroll(function(){
scrolling = true;
element.removeClass('hover');
setTimeout(function() {
if(!scrolling){
element.addClass('hover');
}
}, 200);
scrolling = false;
});
It applies a timeout of 200ms which checks if any other scroll events fired after this scroll. However, the timeout gets registered for every scroll event and fires multiple times after the scrolling ended.
I'm basically looking for a neat solution for this.