@@ -8,6 +8,7 @@ const listenActive = () => {
8
8
[ ...elems ] . forEach ( ( el ) => el . classList . remove ( "active" ) ) ;
9
9
el . classList . add ( "active" ) ;
10
10
// Prevent scroll updates for a short period
11
+ // eslint-disable-next-line no-async-operation
11
12
scrollTimeout = setTimeout ( ( ) => {
12
13
scrollTimeout = null ;
13
14
} , 100 ) ; // Adjust timing as needed
@@ -45,9 +46,7 @@ const updateFunction = () => {
45
46
const scrolledY = window . scrollY ;
46
47
47
48
// Find the last header that is above the current scroll position
48
- let headerOffsets = headers . filter ( ( el ) => {
49
- return scrolledY >= el . offsetTop ;
50
- } ) ;
49
+ let headerOffsets = headers . filter ( ( el ) => scrolledY >= el . offsetTop ) ;
51
50
const lastHeader = headerOffsets . reverse ( ) . shift ( ) ;
52
51
53
52
const pagetocLinks = [ ...document . querySelector ( ".pagetoc" ) . children ] ;
@@ -61,9 +60,8 @@ const updateFunction = () => {
61
60
}
62
61
} ;
63
62
64
- window . addEventListener ( "load" , ( ) => {
63
+ const onLoad = ( ) => {
65
64
const pagetoc = getPagetoc ( ) ;
66
- console . log ( pagetoc ) ;
67
65
var headers = [ ...document . getElementsByClassName ( "header" ) ] ;
68
66
headers . shift ( ) ;
69
67
headers . forEach ( ( header ) => {
@@ -77,4 +75,6 @@ window.addEventListener("load", () => {
77
75
updateFunction ( ) ;
78
76
listenActive ( ) ;
79
77
window . addEventListener ( "scroll" , updateFunction ) ;
80
- } ) ;
78
+ } ;
79
+
80
+ window . addEventListener ( "load" , onLoad ) ;
0 commit comments