Skip to content

Commit

Permalink
fix active/inactive state
Browse files Browse the repository at this point in the history
  • Loading branch information
kirkas committed Oct 9, 2024
1 parent f3e2eae commit 58fd301
Showing 1 changed file with 0 additions and 19 deletions.
19 changes: 0 additions & 19 deletions apps/web/src/components/ThreeHero/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,6 @@ export default function Scene(): JSX.Element {
}, [handleClick]);

useEffect(() => {
const handleVisibilityChange = () => {
updateIsActive();
};

const handleFocus = () => {
updateIsActive();
};

const handleBlur = () => {
updateIsActive();
};

const updateIsActive = () => {
const isFocused = !document.hidden && document.hasFocus();
setIsActive(isFocused);
Expand All @@ -125,20 +113,13 @@ export default function Scene(): JSX.Element {
observer.observe(containerRef.current);
}

document.addEventListener('visibilitychange', handleVisibilityChange);
window.addEventListener('focus', handleFocus);
window.addEventListener('blur', handleBlur);

// Initial check
updateIsActive();

return () => {
if (containerRef.current) {
observer.unobserve(containerRef.current);
}
document.removeEventListener('visibilitychange', handleVisibilityChange);
window.removeEventListener('focus', handleFocus);
window.removeEventListener('blur', handleBlur);
};
}, []);

Expand Down

0 comments on commit 58fd301

Please sign in to comment.