Skip to content

Commit

Permalink
Update src/components/hooks/useScrollVisibility.ts
Browse files Browse the repository at this point in the history
Co-authored-by: codiumai-pr-agent[bot] <138128286+codiumai-pr-agent[bot]@users.noreply.github.com>
  • Loading branch information
tomek-i and codiumai-pr-agent-free[bot] authored Aug 29, 2024
1 parent 36a5bda commit 439558d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/components/hooks/useScrollVisibility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ export const useScrollVisibility = (threshold: number) => {
setIsVisible(scrolledPercentage > threshold);
};

window.addEventListener('scroll', handleScroll);
const debouncedHandleScroll = debounce(handleScroll, 100);
window.addEventListener('scroll', debouncedHandleScroll);
return () => {
window.removeEventListener('scroll', handleScroll);
window.removeEventListener('scroll', debouncedHandleScroll);
};
}, [threshold]);

Expand Down

0 comments on commit 439558d

Please sign in to comment.