javascript - Override scroll up/down function if scrollTop is equal to 0 -


i having trouble one. have transparent header fades out user scrolls down page. user scrolls up, header has black background emphasize existence. working fine, need override happens in function if , if scrolltop equal 0. when user scrolls way top, header returns transparent. current code is:

   $(window).scroll(         {             previoustop: 0         },          function () {         var currenttop = $(window).scrolltop();         if (currenttop < this.previoustop ) {             header.fadein('slow');             header.css('background', 'rgba(0,0,0,.9)');         } else {             header.fadeout();         }         this.previoustop = currenttop;     }); 

any appreciated!

here go: add catch when scrolltop value 0.

  $(window).scroll(         {             previoustop: 0         },          function () {         var currenttop = $(window).scrolltop();         if (currenttop < this.previoustop ) {             if (currenttop != 0 ) { // new if statement here prevents fadein if @ top of page                header.fadein('slow');                header.css('background', 'rgba(0,0,0,.9)');             }         } else {             header.fadeout();         }         this.previoustop = currenttop;     }); 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -