I'm checking the scroll direction with wheelDelta but it returns lots of scroll properties at once. I only need to know if it's up or down and it shouldn't return a value under 500ms after first trigger. I tried to play with setTimeout but couldn't solve it nicely. Any ideas?
var distance = $('.section-two').offset().top,
$window = $(window);
$window.scroll(function() {
if ( $window.scrollTop() >= distance ) {
$('body').css('overflow', 'hidden');
setTimeout(function(){
$(document).bind('mousewheel', function(evt) {
var delta = evt.originalEvent.wheelDelta;
if(delta > 0){
console.log('scrolled up')
} else {
console.log('scrolled down');
}
})
}, 500);
}
});
Here's the codepen example