Created
November 26, 2016 15:19
-
-
Save avtarnanrey/76d1560381797bd98f4ab60f35bdbb46 to your computer and use it in GitHub Desktop.
Hide / Show button on Scroll Function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var position, direction, previous; | |
$(window).scroll(function(){ | |
if( $(this).scrollTop() >= position ){ | |
direction = 'down'; | |
if(direction != previous){ | |
$('.menu-toggle').addClass('hide'); | |
previous = direction; | |
} | |
} else { | |
direction = 'up'; | |
if(direction !== previous){ | |
$('.menu-toggle').removeClass('hide'); | |
previous = direction; | |
} | |
} | |
position = $(this).scrollTop(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment