<pre>var prevScrollpos = window.pageYOffset; window.addEventListener("scroll", hideNav); window.addEventListener("scroll", hideBreadcrumbs); window.addEventListener("scroll", hideMenu); window.addEventListener("scroll", progressBar); function hideBreadcrumbs() { var currentScrollPos = window.pageYOffset; if (prevScrollpos > currentScrollPos){ document.getElementsByClassName("breadcrumb").style.top = "200px"; } else { document.getElementsByClassName("breadcrumb").style.top = "-135px"; } prevScrollpos = currentScrollPos; } // It is just this following section of code regarding hideNav to which I am referring // function hideNav() { var currentScrollPos = window.pageYOffset; if (prevScrollpos > currentScrollPos){ document.getElementById("topnav").style.top = "0px"; } else { document.getElementById("topnav").style.top = "-135px"; } prevScrollpos = currentScrollPos; } function hideMenu() { var currentScrollPos = window.pageYOffset; if (prevScrollpos > currentScrollPos){ document.getElementsByClassName("menu-wrap").style.top = "0px"; } else { document.getElementsByClassName("menu-wrap").style.top = "-75px"; } prevScrollpos = currentScrollPos; } function progressBar() { var winScroll = document.body.scrollTop || document.documentElement.scrollTop; var height = document.documentElement.scrollHeight - document.documentElement.clientHeight; var scrolled = (winScroll / height) * 100; document.getElementById("myBar").style.width = scrolled + "%"; }
const mediaQueryList = window.matchMedia("(max-width: 1079px)"); const hideNav = function(){ const currentScrollPos = window.pageYOffset; if (mediaQueryList.matches && currentScrollPos >= prevScrollPos) { document.getElementById("topnav").style.top = "-135px"; } else { document.getElementById("topnav").style.top = "0"; } prevScrollPos = currentScrollPos; }; window.addEventListener("scroll", hideNav); mediaQueryList.addListener(hideNav);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)