@@ -22,26 +22,13 @@ function throttle(fn, interval) {
2222 } ;
2323}
2424
25- function scrollNavbar ( ) {
26- const scrollPosition = document . documentElement . scrollTop ;
27-
28- //Navbar Clone
29- const navbarClone = document . getElementById ( "navbar-clone" ) ;
30-
31- // Make navbar sticky, by activating a second, duplicate navbar
32- // that is fixed to the top of the screen.
33- navbarClone . classList . toggle ( "is-active" , scrollPosition > 50 ) ;
34- }
35-
3625// Highlight currently scrolled to header in shortcuts
3726// Based on https://stackoverflow.com/a/32396543/214686
3827// and
3928// https://stackoverflow.com/a/57494988/214686
4029// which fixes some issues with the first, particularly
4130// around scrolling upward.
42- function scrollHeadersAndNavbar ( ) {
43- scrollNavbar ( ) ;
44-
31+ function scrollHeaders ( ) {
4532 const scrollPosition = document . documentElement . scrollTop ;
4633 const headers = Array . from (
4734 document . querySelectorAll ( ":is(h1, h2, h3, h4, h5, h6)[id]" ) ,
@@ -79,14 +66,14 @@ function scrollHeadersAndNavbar() {
7966 } ) ;
8067}
8168
82- const throttledScrollHeadersAndNavbar = throttle ( scrollHeadersAndNavbar , 100 ) ;
69+ const throttledScrollHeaders = throttle ( scrollHeaders , 100 ) ;
8370
8471function bindScroll ( ) {
85- window . addEventListener ( "scroll" , throttledScrollHeadersAndNavbar ) ;
72+ window . addEventListener ( "scroll" , throttledScrollHeaders ) ;
8673}
8774
8875function unbindScroll ( ) {
89- window . removeEventListener ( "scroll" , throttledScrollHeadersAndNavbar ) ;
76+ window . removeEventListener ( "scroll" , throttledScrollHeaders ) ;
9077}
9178
9279function remToPx ( rem ) {
@@ -142,9 +129,6 @@ function setupShortcuts(shortcutDepth = 2) {
142129 // Done moving to clicked header; re-enable
143130 // scroll highlighting of shortcuts
144131 bindScroll ( ) ;
145-
146- // After scroll, display the navbar, if necessary
147- scrollNavbar ( ) ;
148132 } ) ;
149133 } ) ;
150134 } ) ;
0 commit comments