MediaWiki:Gadget-stickyHeader.js
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)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/*
*
* @see Based on https://minecraft.wiki/w/MediaWiki:Gadget-stickyHeader.js
*/
$(function() {
$('#left-navigation, #right-navigation').wrapAll('<div id="stickyTop"></div>').wrapAll('<div id="stickyTopFlex"></div>');
$('<div id="stickyTopBack"></div>').appendTo('#stickyTop');
var stickyTop = $('#stickyTop');
var nsTop = $('#p-namespaces').offset().top;
function sticky() {
var scrollTop = $(window).scrollTop();
if (scrollTop > nsTop) {
stickyTop.addClass('stick');
} else {
stickyTop.removeClass('stick');
}
};
sticky();
$(window).scroll(sticky);
});