Skip to content

Commit

Permalink
fix(navbar): shouldHideOnScroll fixed (#3315)
Browse files Browse the repository at this point in the history
* fix(navbar): shouldHideOnScroll fixed

* Update packages/hooks/use-scroll-position/src/index.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update index.ts

* fix(navbar): applying suggested changes

---------

Co-authored-by: Pratyush <conenct2pratyush@gmail.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
3 people committed Jul 6, 2024
1 parent 444d320 commit 35e709d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/happy-cameras-whisper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nextui-org/use-scroll-position": patch
---

clearing throttleTimeout when it is supposed to be null in useScrollPosition (#3139)
6 changes: 4 additions & 2 deletions packages/hooks/use-scroll-position/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ export const useScrollPosition = (props: UseScrollPositionOptions): ScrollValue

const handleScroll = () => {
if (delay) {
if (throttleTimeout.current === null) {
throttleTimeout.current = setTimeout(handler, delay);
if (throttleTimeout.current) {
clearTimeout(throttleTimeout.current);
}

throttleTimeout.current = setTimeout(handler, delay);
} else {
handler();
}
Expand Down

0 comments on commit 35e709d

Please sign in to comment.