Skip to content

Commit

Permalink
fix(hooks): disable IntersectionObserver on view
Browse files Browse the repository at this point in the history
  • Loading branch information
caugner committed Oct 30, 2024
1 parent 143719f commit 2560d79
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion client/src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ export function useViewed(
) {
const timer = useRef<ViewedTimer>({ timeout: null });
const isVisible = usePageVisibility();
const [node, setNode] = useState<HTMLElement>();
const [node, setNode] = useState<HTMLElement | undefined>();
const isIntersecting = useIsIntersecting(node, intersectionObserverOptions);

useEffect(() => {
Expand All @@ -301,6 +301,7 @@ export function useViewed(
timer.current = {
timeout: window.setTimeout(() => {
timer.current = { timeout: -1 };
setNode(undefined);
callback();
}, 1000),
};
Expand Down

0 comments on commit 2560d79

Please sign in to comment.