MediaWiki:SupportPage.js: Difference between revisions
Content deleted Content added
minor cleanup |
No edit summary |
||
Line 20:
topMenu = $('#toc > ul'),
menuItems = topMenu.find('a'), // All TOC links
scrollItems = $('.sp-content .mw-headline')
scrollOffset = 16, // Offset in px
scrollDuration = 500; // in ms
/* Bind click handler to menu items so we can get a fancy scroll animation */
menuItems.click(function(e){
var id = $(this).attr('href').replace('#', '')
$('html, body').stop().animate({
scrollTop: offsetTop - scrollOffset
},
e.preventDefault();
});
Line 34 ⟶ 36:
/* Highlighting current section in TOC */
$(window).scroll(function(){
var fromTop = $(this).scrollTop(); // Get container scroll position
// Get id of current scroll item
var cur = scrollItems.map(function(){
if ( $(this).offset().top < fromTop ) {
return this;
}
});
// Get the id of the current element
cur = cur[cur.length-1];
|