You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 7271438
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: js/navigation/navigation.js
+35-6Lines changed: 35 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,43 @@
1
1
/* js/navigation/navigation.js
2
2
Purpose : the top navigation: scroll-spy (which link is active), the sliding nav pill, and the flower nav (a flower per link and a butterfly that flies to your section).
3
-
Owns : scrollSpy(), pill(), flowerNav(). Each is called by a legacy file at the spot its code used to run (scroll-spy first, then the pill, then the flower nav: the flower nav and pill both watch the .nav classes that scroll-spy sets).
3
+
Owns : mobileMenu(), scrollSpy(), pill(), flowerNav(). Each is called by a legacy file at the spot its code used to run (scroll-spy first, then the pill, then the flower nav: the flower nav and pill both watch the .nav classes that scroll-spy sets).
4
4
Uses : nothing. Used by: js/legacy/020, 110, 120 (until Phase D wiring).
5
-
Mobile / reduced motion: there is no hamburger menu (the pill nav is used at every width); the nav shrinks after 80px of scroll; the flower nav butterfly is part of the page decoration and respects the existing CSS reduced-motion rules.
5
+
Mobile / reduced motion: at <=640px the pill nav is hidden and the .m-header + .m-menu dropdown (hamburger) show instead; mobileMenu() builds its links from the .nav links so labels, order and hrefs have one source; the nav shrinks after 80px of scroll; the flower nav butterfly is part of the page decoration and respects the existing CSS reduced-motion rules.
6
6
Moved verbatim from the legacy files (Migration Step 7); behaviour, order and timing unchanged. */
(()=>{constsecs=[...document.querySelectorAll('section[id]')],links=[...document.querySelectorAll('.nav a, .m-menu a')];lettk=false,cur='';addEventListener('scroll',()=>{if(tk)return;tk=true;requestAnimationFrame(()=>{tk=false;letc='about';for(constsofsecs){if(s.id!=='home'&&scrollY>=s.offsetTop-200)c=s.id;}if(c===cur)return;cur=c;links.forEach(l=>{conston=l.getAttribute('href')==='#'+c;if(l.classList.contains('active')!==on)l.classList.toggle('active',on);});});},{passive:true});})();
12
43
}
@@ -22,11 +53,9 @@ MB.define('navigation.navigation', [], function () {
0 commit comments