Thursday, March 1, 2018

How to get direction of scroll top or down in jquery

var previousScroll = 0;
$(window).scroll(function() {

 var currentScroll = $(this).scrollTop();
       if (currentScroll > previousScroll){
           $('#sc1_dwn').css('height',('+=15'));
       } else {
          $('#sc1_dwn').css('height',('-=15'));
       }
       previousScroll = currentScroll;
    
});

No comments:

Post a Comment