fix(hook): re-attached scroll event behavior in useScrollPosition (#3247)

* fix: initialize throttleTimeout in cleanup function

* chore(changeset): add changeset

---------

Co-authored-by: WK Wong <wingkwong.code@gmail.com>
This commit is contained in:
vetan2 2024-09-12 23:09:12 +09:00 committed by GitHub
parent 142f394cb5
commit b0728e3c38
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 0 deletions

View File

@ -0,0 +1,5 @@
---
"@nextui-org/use-scroll-position": patch
---
re-attach scroll event behavior in `useScrollPosition`

View File

@ -77,6 +77,7 @@ export const useScrollPosition = (props: UseScrollPositionOptions): ScrollValue
target.removeEventListener("scroll", handleScroll);
if (throttleTimeout.current) {
clearTimeout(throttleTimeout.current);
throttleTimeout.current = null;
}
};
}, [elementRef?.current, delay, handler, isEnabled]);