I'm trying to make it so that my nav-bar 'hides' (via animation) when wheelDelta is negative (scroll down), and when wheelDelta is positive (scroll up) the nav-bar re-appears (animation).
Here is my JavaScript code for this:
/* Scrolling Animation */
$(document).scroll(function () {
var evt = window.event();
var delta = evt.wheelDelta;
if ( delta >= 120 ){
$('.nav').animate({ top: '-65px' }, 200);
$('body').animate({ top: '0px' }, 200);
}
else if ( delta <= -120 ){
$('.nav').animate({ top: '0px' }, 200);
$('body').animate({ top: '65px' }, 200);
}
});
It doesn't work, though. I've done some troubleshooting and I've figured out that the problem is that the delta variable is undefined. So I think that I just don't know how to properly get the wheelDelta property.
Can someone show me an example of how to get the wheelDelta property value and store it in a variable??
Thanks.