Skip to content Skip to sidebar Skip to footer

How Do I Get The Wheeldelta Property?

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 (anim

Solution 1:

window.event is not a function. Also as mentioned in comments scroll is different from mousewheel. Try this:

   $(document).on('mousewheel',function (evt) {
      var delta = evt.originalEvent.wheelDelta;
      console.log('scroll ' + delta, evt);
      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);
      }
    });

Post a Comment for "How Do I Get The Wheeldelta Property?"