/* When the user scrolls down, hide the navbar. When the user scrolls up, show the navbar */ $(document).ready(function() { var instance = $('body').overlayScrollbars(); var prevScrollpos = instance.scroll().position.y; console.log(prevScrollpos); window.onscroll = function() { var currentScrollPos = instance.scroll().position.y; console.log(currentScrollPos); if (prevScrollpos > currentScrollPos) { $("#header").css({"top" : "0"}); } else { $("#header").css({"top" : "-50px"}); } prevScrollpos = currentScrollPos; } });