auto-claude: subtask-2-1 - Add visibility detection to GlobalBackground component

This commit is contained in:
2026-01-25 06:29:03 +01:00
parent 2b096416a0
commit 43593c7654
@@ -1,8 +1,20 @@
import { usePageVisibility } from '@/hooks/usePageVisibility';
import { useIntersectionObserver } from '@/hooks/useIntersectionObserver';
const GlobalBackground = () => { const GlobalBackground = () => {
const isPageVisible = usePageVisibility();
const { ref, isIntersecting } = useIntersectionObserver<HTMLDivElement>({
threshold: 0.1,
rootMargin: '0px'
});
const shouldAnimate = isPageVisible && isIntersecting;
return ( return (
<> <>
{/* Background layer */} {/* Background layer */}
<div <div
ref={ref}
className="fixed inset-0 bg-zinc-900" className="fixed inset-0 bg-zinc-900"
style={{ zIndex: -2 }} style={{ zIndex: -2 }}
/> />
@@ -36,6 +48,8 @@ const GlobalBackground = () => {
strokeWidth="1" strokeWidth="1"
opacity="0.2" opacity="0.2"
> >
{shouldAnimate && (
<>
<animate <animate
attributeName="y1" attributeName="y1"
values="20%;80%;20%" values="20%;80%;20%"
@@ -48,6 +62,8 @@ const GlobalBackground = () => {
dur="10s" dur="10s"
repeatCount="indefinite" repeatCount="indefinite"
/> />
</>
)}
</line> </line>
<line <line
@@ -59,12 +75,14 @@ const GlobalBackground = () => {
strokeWidth="1" strokeWidth="1"
opacity="0.15" opacity="0.15"
> >
{shouldAnimate && (
<animate <animate
attributeName="x1" attributeName="x1"
values="0%;100%;0%" values="0%;100%;0%"
dur="15s" dur="15s"
repeatCount="indefinite" repeatCount="indefinite"
/> />
)}
</line> </line>
<line <line
@@ -76,6 +94,8 @@ const GlobalBackground = () => {
strokeWidth="1" strokeWidth="1"
opacity="0.1" opacity="0.1"
> >
{shouldAnimate && (
<>
<animate <animate
attributeName="x1" attributeName="x1"
values="20%;80%;20%" values="20%;80%;20%"
@@ -88,6 +108,8 @@ const GlobalBackground = () => {
dur="12s" dur="12s"
repeatCount="indefinite" repeatCount="indefinite"
/> />
</>
)}
</line> </line>
</svg> </svg>
</div> </div>