Cancel scroll watcher timeout
This commit is contained in:
@ -37,6 +37,11 @@ export function useScrollWatcher(effect: Effect, delay: number): void {
|
||||
}
|
||||
|
||||
window.addEventListener('scroll', handleScroll)
|
||||
return () => window.removeEventListener('scroll', handleScroll)
|
||||
return () => {
|
||||
if (throttleTimeout.current) {
|
||||
clearTimeout(throttleTimeout.current)
|
||||
}
|
||||
window.removeEventListener('scroll', handleScroll)
|
||||
}
|
||||
}, [currentOffset, delay, effect])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user