How can I detect the scroll direction (mousewheel up/down) without scrolling the page? My page wrapper has a height of 100%, so there is no content to scroll, but I need the scroll direction from the mousewheel.
Since Google Maps does the same (using the mousehweel for zoom without "scrolling" the page), I wonder how to achieve this.
If you are talking about the mouse wheel, you can use addEventListener on the window. event.wheelDelta will have a delta of -120 or 120, for scrolling down and up, respectively.:
window.addEventListener('mousewheel', function(e){
wDelta = e.wheelDelta < 0 ? 'down' : 'up';
console.log(wDelta);
});
JSFiddle
Of course, you'll need to cater for different browsers. But i'll leave that up to you. See here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With