More actions
Mahnsoo.choi (talk | contribs) No edit summary |
Mahnsoo.choi (talk | contribs) No edit summary |
||
| Line 15: | Line 15: | ||
if ( previousScrollPoint > currentScrollPoint || | if ( previousScrollPoint > currentScrollPoint || | ||
1 > currentScrollPoint ) { | (1 > currentScrollPoint && currentScrollPoint > -5-document.body.scrollHeight) { | ||
document.getElementById("mw-navigation").style.top = "0"; | document.getElementById("mw-navigation").style.top = "0"; | ||
} else { | } else { | ||
Revision as of 11:50, 23 February 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 = window.pageYOffset;
window.onscroll = function() {
var currentScrollPoint = window.scrollY;
if (previousScrollPoint - currentScrollPoint < 5 &&
previousScrollPoint - currentScrollPoint > -5) {
return false;
}
if ( previousScrollPoint > currentScrollPoint ||
(1 > currentScrollPoint && currentScrollPoint > -5-document.body.scrollHeight) {
document.getElementById("mw-navigation").style.top = "0";
} else {
document.getElementById("mw-navigation").style.top = "-50px";
}
previousScrollPoint = currentScrollPoint;
}