More actions
Mahnsoo.choi (talk | contribs) No edit summary |
Mahnsoo.choi (talk | contribs) No edit summary |
||
Line 16: | Line 16: | ||
if ( previousScrollPoint > currentScrollPoint || | if ( previousScrollPoint > currentScrollPoint || | ||
1 > currentScrollPoint ) { | 1 > currentScrollPoint ) { | ||
document.getElementById(" | document.getElementById("page-banner").style.display = "block"; | ||
document.getElementById("mw-navigation").style.top = "0"; | document.getElementById("mw-navigation").style.top = "0"; | ||
} else { | } else { | ||
document.getElementById(" | document.getElementById("page-banner").style.display = "none"; | ||
document.getElementById("mw-navigation").style.top = "-50px"; | document.getElementById("mw-navigation").style.top = "-50px"; | ||
} | } | ||
previousScrollPoint = currentScrollPoint; | previousScrollPoint = currentScrollPoint; | ||
} | } |
Revision as of 17:14, 22 June 2019
/* Any JavaScript here will be loaded for all users on every page load. */ /* * Hide the navigation bar on scroll down (page push up). * Common.css needs to contain navbar { transition: top 0.5s; } or similar. */ var previousScrollPoint = 0; window.onscroll = function() { var currentScrollPoint = window.scrollY || document.documentElement.scrollTop || document.body.scrollTop; if (previousScrollPoint - currentScrollPoint < 40 && previousScrollPoint - currentScrollPoint > -40) { return; } if ( previousScrollPoint > currentScrollPoint || 1 > currentScrollPoint ) { document.getElementById("page-banner").style.display = "block"; document.getElementById("mw-navigation").style.top = "0"; } else { document.getElementById("page-banner").style.display = "none"; document.getElementById("mw-navigation").style.top = "-50px"; } previousScrollPoint = currentScrollPoint; }