Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */


/**
 * Prevent Leaflet maps from auto-scrolling page on load
 * This intercepts scroll attempts during map initialization
 */
(function() {
    'use strict';
    
    // Only apply fix if we're near the top of the page
    if (window.scrollY > 100) return;
    
    var savedPosition = window.scrollY;
    var scrollLocked = true;
    
    // Temporarily override scrollIntoView to prevent map from scrolling page
    var originalScrollIntoView = Element.prototype.scrollIntoView;
    Element.prototype.scrollIntoView = function(options) {
        // Allow scrollIntoView for non-map elements after unlock
        if (!scrollLocked || !this.closest('.leaflet-container, .smw-format-leaflet')) {
            originalScrollIntoView.call(this, options);
        }
    };
    
    // Also intercept any direct scroll attempts
    var originalScrollTo = window.scrollTo.bind(window);
    window.scrollTo = function(x, y) {
        if (scrollLocked && savedPosition < 100) {
            return; // Block scroll during initialization
        }
        originalScrollTo(x, y);
    };
    
    // Restore normal behavior after maps have initialized
    setTimeout(function() {
        scrollLocked = false;
        Element.prototype.scrollIntoView = originalScrollIntoView;
        window.scrollTo = originalScrollTo;
    }, 1000);
})();
MediaWiki Appliance - Powered by TurnKey Linux