Explorar o código

feat(docs): Scroll active nav menu item into view

Michael Bromley %!s(int64=5) %!d(string=hai) anos
pai
achega
6fbe1db9d7
Modificáronse 1 ficheiros con 5 adicións e 0 borrados
  1. 5 0
      docs/assets/scripts/nav-menu.ts

+ 5 - 0
docs/assets/scripts/nav-menu.ts

@@ -1,6 +1,11 @@
 export function initNavMenu() {
     const sections = document.querySelectorAll('nav li.section');
     sections.forEach(makeExpandable);
+
+    const activeLink = document.querySelector('nav a.active');
+    if (activeLink) {
+        activeLink.scrollIntoView({ block: 'center' });
+    }
 }
 
 function makeExpandable(section: Element) {