Toggle menu
288
407
15
3.9K
QCLab
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

MediaWiki:Common.js: Difference between revisions

MediaWiki interface page
No edit summary
No edit summary
Line 8: Line 8:
window.onscroll = function() {
window.onscroll = function() {
     var currentScrollPoint = window.pageYOffset || document.documentElement.scrollTop;
     var currentScrollPoint = window.pageYOffset || document.documentElement.scrollTop;
    if (previousScrollPoint - currentScrollPoint < 30 &&
        previousScrollPoint - currentScrollPoint > -30) {
        return true;
    }
     if ( previousScrollPoint > currentScrollPoint ||
     if ( previousScrollPoint > currentScrollPoint ||
         (1 > currentScrollPoint && currentScrollPoint > -document.body.scrollHeight) ) {
         (1 > currentScrollPoint && currentScrollPoint > -document.body.scrollHeight-1) ) {
         document.getElementById("mw-navigation").style.top = "0";
         document.getElementById("mw-navigation").style.top = "0";
     } else {
     } else {

Revision as of 11:41, 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.pageYOffset || document.documentElement.scrollTop;
    if ( previousScrollPoint > currentScrollPoint ||
         (1 > currentScrollPoint && currentScrollPoint > -document.body.scrollHeight-1) ) {
        document.getElementById("mw-navigation").style.top = "0";
    } else {
        document.getElementById("mw-navigation").style.top = "-50px";
    }
    previousScrollPoint = currentScrollPoint;
}