Skip to content

Instantly share code, notes, and snippets.

@hongthaiphi
Created October 27, 2018 16:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hongthaiphi/232e5566d529ed633276ae7d1451c937 to your computer and use it in GitHub Desktop.
Save hongthaiphi/232e5566d529ed633276ae7d1451c937 to your computer and use it in GitHub Desktop.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
var lastScrollTop = 0;
$(window).scroll(function(event){
var st = $(this).scrollTop();
if (st > lastScrollTop){
// downscroll code
$('#site-navigation').removeClass('fixed-menu');
} else {
// upscroll code
$('#site-navigation').addClass('fixed-menu');
}
lastScrollTop = st;
});</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment