MediaWiki:SupportPage.js: Difference between revisions

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