File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ export const useActiveHeaderLinks = ({
2020 const router = useRouter ( )
2121 const page = usePageData ( )
2222
23- const setActiveRouteHash = ( ) : void => {
23+ const setActiveRouteHash = debounce ( ( ) : void => {
2424 // get all header links
2525 const headerLinks : HTMLAnchorElement [ ] = Array . from (
2626 document . querySelectorAll ( headerLinkSelector )
@@ -104,16 +104,16 @@ export const useActiveHeaderLinks = ({
104104 } )
105105 return
106106 }
107- }
107+ } , delay )
108108
109- const onScroll = debounce ( ( ) => setActiveRouteHash ( ) , delay )
109+ const onScroll = ( ) : Promise < void > => setActiveRouteHash ( )
110110
111111 onMounted ( ( ) => {
112- onScroll ( )
113- window . addEventListener ( 'scroll' , ( ) => onScroll ( ) )
112+ setActiveRouteHash ( )
113+ window . addEventListener ( 'scroll' , onScroll )
114114 } )
115115 onBeforeUnmount ( ( ) => {
116- window . removeEventListener ( 'scroll' , ( ) => onScroll ( ) )
116+ window . removeEventListener ( 'scroll' , onScroll )
117117 } )
118118 watch (
119119 ( ) => page . value . path ,
You can’t perform that action at this time.
0 commit comments