MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
Mahnsoo.choi (talk | contribs) Created page with "→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..." |
Mahnsoo.choi (talk | contribs) No edit summary |
||
| (5 intermediate revisions by the same user not shown) | |||
| Line 7: | Line 7: | ||
var previousScrollPoint = window.pageYOffset; | var previousScrollPoint = window.pageYOffset; | ||
window.onscroll = function() { | window.onscroll = function() { | ||
var currentScrollPoint = window. | var currentScrollPoint = window.scrollY || document.documentElement.scrollTop || document.body.scrollTop; | ||
if (previousScrollPoint > currentScrollPoint || 1 > currentScrollPoint) { | |||
if (previousScrollPoint - currentScrollPoint < 40 && | |||
previousScrollPoint - currentScrollPoint > -40) { | |||
return; | |||
} | |||
if ( previousScrollPoint > currentScrollPoint || | |||
1 > currentScrollPoint ) { | |||
document.getElementById("mw-navigation").style.top = "0"; | document.getElementById("mw-navigation").style.top = "0"; | ||
} else { | } else { | ||
Latest revision as of 15:54, 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 || document.documentElement.scrollTop || document.body.scrollTop;
if (previousScrollPoint - currentScrollPoint < 40 &&
previousScrollPoint - currentScrollPoint > -40) {
return;
}
if ( previousScrollPoint > currentScrollPoint ||
1 > currentScrollPoint ) {
document.getElementById("mw-navigation").style.top = "0";
} else {
document.getElementById("mw-navigation").style.top = "-50px";
}
previousScrollPoint = currentScrollPoint;
}