Skip to content

Commit 6a1b52e

Browse files
committed
reduce observer debounce time
1 parent 605c7fa commit 6a1b52e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/components/react/ScrollToTop.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,13 @@ const ScrollToTop: React.FC<Props> = ({ children }) => {
5151
});
5252

5353
if (linkRef.current) {
54-
isAtTop || isAtBottom ? hideLink(linkRef) : showLink(linkRef);
54+
if (isAtTop || isAtBottom) hideLink(linkRef);
55+
else showLink(linkRef);
5556
}
5657
};
5758

58-
// bellow 200 or it will break again
59-
const debouncedCallback = debounce(callback, 100);
59+
// bellow 100 or it will break again on fast scroll
60+
const debouncedCallback = debounce(callback, 20);
6061
const intersect = new IntersectionObserver(debouncedCallback);
6162

6263
if (topRef.current) intersect.observe(topRef.current);

0 commit comments

Comments
 (0)