@@ -23,7 +23,7 @@ export const useActiveHeaderLinks = ({
23
23
const scrollTop = Math . max (
24
24
window . scrollY ,
25
25
document . documentElement . scrollTop ,
26
- document . body . scrollTop
26
+ document . body . scrollTop ,
27
27
)
28
28
// check if we are at page top
29
29
const isAtPageTop = Math . abs ( scrollTop - 0 ) < offset
@@ -39,23 +39,23 @@ export const useActiveHeaderLinks = ({
39
39
// get the total scroll length of current page
40
40
const scrollHeight = Math . max (
41
41
document . documentElement . scrollHeight ,
42
- document . body . scrollHeight
42
+ document . body . scrollHeight ,
43
43
)
44
44
// check if we have reached page bottom
45
45
// notice the `scrollBottom` might not be exactly equal to `scrollHeight`, so we add offset here
46
46
const isAtPageBottom = Math . abs ( scrollHeight - scrollBottom ) < offset
47
47
48
48
// get all header links
49
49
const headerLinks : HTMLAnchorElement [ ] = Array . from (
50
- document . querySelectorAll ( headerLinkSelector )
50
+ document . querySelectorAll ( headerLinkSelector ) ,
51
51
)
52
52
// get all header anchors
53
53
const headerAnchors : HTMLAnchorElement [ ] = Array . from (
54
- document . querySelectorAll ( headerAnchorSelector )
54
+ document . querySelectorAll ( headerAnchorSelector ) ,
55
55
)
56
56
// filter anchors that do not have corresponding links
57
57
const existedHeaderAnchors = headerAnchors . filter ( ( anchor ) =>
58
- headerLinks . some ( ( link ) => link . hash === anchor . hash )
58
+ headerLinks . some ( ( link ) => link . hash === anchor . hash ) ,
59
59
)
60
60
61
61
for ( let i = 0 ; i < existedHeaderAnchors . length ; i ++ ) {
0 commit comments