More actions
No edit summary |
No edit summary |
||
| Line 92: | Line 92: | ||
anchor.addEventListener('click', function(e) { | anchor.addEventListener('click', function(e) { | ||
e.preventDefault(); // Block native browser jump immediately | e.preventDefault(); // Block native browser jump immediately | ||
const hash = decodeURIComponent(this.getAttribute('href')).substring(1); | |||
const heading = document.getElementById(hash); | |||
if (heading) { | |||
expandCitizenSectionFromHeading(heading); | |||
requestAnimationFrame(() => { | |||
requestAnimationFrame(() => { | |||
smoothScrollToHeading(heading); | |||
}); | |||
}); | |||
} | |||
}); | |||
}); | |||
}, 200); | |||
} | |||
}); | |||
// === Intercept in-page wiki links like [[#HeadingName]] === | |||
mw.hook('wikipage.content').add(function($content) { | |||
if (window.innerWidth >= 768) { | |||
setTimeout(() => { | |||
document.querySelectorAll('#mw-content-text a[href^="#"]').forEach(function(anchor) { | |||
anchor.addEventListener('click', function(e) { | |||
e.preventDefault(); // Block native jump | |||
const hash = decodeURIComponent(this.getAttribute('href')).substring(1); | const hash = decodeURIComponent(this.getAttribute('href')).substring(1); | ||