MediaWiki:SupportPage.js: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
No edit summary |
if scrolled, add pinned class to navbar |
||
Line 59: | Line 59: | ||
// Highlight current section in toc |
// Highlight current section in toc |
||
var lastSection; |
var lastSection; |
||
function |
function scrollFunction() { |
||
var fromTop = $(this).scrollTop(); // Get container scroll position |
var fromTop = $(this).scrollTop(); // Get container scroll position |
||
var currentSection = toc.filter(function(item) { |
var currentSection = toc.filter(function(item) { |
||
return fromTop > item.anchor.offset().top - 64; |
return fromTop > item.anchor.offset().top - 64; |
||
}); |
}); |
||
currentSection = currentSection[currentSection.length - 1]; |
currentSection = currentSection[currentSection.length - 1]; |
||
if ( currentSection && lastSection !== currentSection ) { |
if ( currentSection && lastSection !== currentSection ) { |
||
Line 69: | Line 70: | ||
$('#toc > ul a').removeClass('-active'); |
$('#toc > ul a').removeClass('-active'); |
||
currentSection.link.addClass('-active'); |
currentSection.link.addClass('-active'); |
||
} |
|||
if ( fromTop === 0 ) { |
|||
$('.sp-logo-nav-container').removeClass('pinned'); |
|||
} else { |
|||
$('.sp-logo-nav-container').addClass('pinned'); |
|||
} |
} |
||
} |
} |
||
scrollFunction(); |
|||
$(window).scroll( |
$(window).scroll( scrollFunction ); |
||
/* -- end of table of contents code -- */ |
/* -- end of table of contents code -- */ |
||