diff --git a/src/components/layout/GlobalBackground.tsx b/src/components/layout/GlobalBackground.tsx index ca29edc..a33ccd2 100644 --- a/src/components/layout/GlobalBackground.tsx +++ b/src/components/layout/GlobalBackground.tsx @@ -1,8 +1,20 @@ +import { usePageVisibility } from '@/hooks/usePageVisibility'; +import { useIntersectionObserver } from '@/hooks/useIntersectionObserver'; + const GlobalBackground = () => { + const isPageVisible = usePageVisibility(); + const { ref, isIntersecting } = useIntersectionObserver({ + threshold: 0.1, + rootMargin: '0px' + }); + + const shouldAnimate = isPageVisible && isIntersecting; + return ( <> {/* Background layer */}
@@ -36,18 +48,22 @@ const GlobalBackground = () => { strokeWidth="1" opacity="0.2" > - - + {shouldAnimate && ( + <> + + + + )} { strokeWidth="1" opacity="0.15" > - + {shouldAnimate && ( + + )} { strokeWidth="1" opacity="0.1" > - - + {shouldAnimate && ( + <> + + + + )}