MediaWiki:Common.js: Difference between revisions

From Qubits
Jump to navigation Jump to search
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..."
(No difference)

Revision as of 02:56, 22 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;
    if (previousScrollPoint > currentScrollPoint || 1 > currentScrollPoint) {
        document.getElementById("mw-navigation").style.top = "0";
    } else {
        document.getElementById("mw-navigation").style.top = "-50px";
    }
    previousScrollPoint = currentScrollPoint;
}