@@ -22,26 +22,13 @@ function throttle(fn, interval) {
22
22
} ;
23
23
}
24
24
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
-
36
25
// Highlight currently scrolled to header in shortcuts
37
26
// Based on https://stackoverflow.com/a/32396543/214686
38
27
// and
39
28
// https://stackoverflow.com/a/57494988/214686
40
29
// which fixes some issues with the first, particularly
41
30
// around scrolling upward.
42
- function scrollHeadersAndNavbar ( ) {
43
- scrollNavbar ( ) ;
44
-
31
+ function scrollHeaders ( ) {
45
32
const scrollPosition = document . documentElement . scrollTop ;
46
33
const headers = Array . from (
47
34
document . querySelectorAll ( ":is(h1, h2, h3, h4, h5, h6)[id]" ) ,
@@ -79,14 +66,14 @@ function scrollHeadersAndNavbar() {
79
66
} ) ;
80
67
}
81
68
82
- const throttledScrollHeadersAndNavbar = throttle ( scrollHeadersAndNavbar , 100 ) ;
69
+ const throttledScrollHeaders = throttle ( scrollHeaders , 100 ) ;
83
70
84
71
function bindScroll ( ) {
85
- window . addEventListener ( "scroll" , throttledScrollHeadersAndNavbar ) ;
72
+ window . addEventListener ( "scroll" , throttledScrollHeaders ) ;
86
73
}
87
74
88
75
function unbindScroll ( ) {
89
- window . removeEventListener ( "scroll" , throttledScrollHeadersAndNavbar ) ;
76
+ window . removeEventListener ( "scroll" , throttledScrollHeaders ) ;
90
77
}
91
78
92
79
function remToPx ( rem ) {
@@ -142,9 +129,6 @@ function setupShortcuts(shortcutDepth = 2) {
142
129
// Done moving to clicked header; re-enable
143
130
// scroll highlighting of shortcuts
144
131
bindScroll ( ) ;
145
-
146
- // After scroll, display the navbar, if necessary
147
- scrollNavbar ( ) ;
148
132
} ) ;
149
133
} ) ;
150
134
} ) ;
0 commit comments