mirror of
https://github.com/StarCitizenTools/mediawiki-skins-Citizen.git
synced 2024-11-15 02:24:04 +00:00
fix: incorrect ToC scrollspy highlight
This commit is contained in:
parent
09b399ccf0
commit
0746895e9b
|
@ -35,11 +35,17 @@ function SmoothScroll() {
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function ScrollSpy() {
|
function ScrollSpy() {
|
||||||
var sections = document.querySelectorAll( '.mw-headline' );
|
var sections = document.querySelectorAll( '.mw-headline' ),
|
||||||
|
mwbody = document.querySelector( '.mw-body' ),
|
||||||
|
mwbodyStyle = window.getComputedStyle( mwbody ),
|
||||||
|
scrollOffset = parseInt( mwbodyStyle.marginTop, 10 ) + 1;
|
||||||
|
|
||||||
window.addEventListener( 'scroll', function () {
|
window.addEventListener( 'scroll', function () {
|
||||||
var scrollPos = document.documentElement.scrollTop || document.body.scrollTop,
|
var scrollPos = document.documentElement.scrollTop || document.body.scrollTop,
|
||||||
section, id, node, active;
|
section, id, node, active;
|
||||||
|
|
||||||
|
scrollPos += scrollOffset;
|
||||||
|
|
||||||
for ( section in sections ) {
|
for ( section in sections ) {
|
||||||
if (
|
if (
|
||||||
Object.prototype.hasOwnProperty.call( sections, section ) &&
|
Object.prototype.hasOwnProperty.call( sections, section ) &&
|
||||||
|
|
Loading…
Reference in a new issue