"use client"; import { useEffect, useRef, useState, type CSSProperties, type ReactNode } from "react"; /** * Scroll-reveal wrapper. Starts hidden (via the `.reveal` class) and marks * itself in view the first time it intersects the viewport, letting CSS handle * the rise-and-fade. Honours reduced-motion through the stylesheet. */ export function Reveal({ children, delay = 0, className = "", }: { children: ReactNode; delay?: number; className?: string; }) { const ref = useRef(null); const [inView, setInView] = useState(false); useEffect(() => { const node = ref.current; if (!node) { return; } if (typeof IntersectionObserver === "undefined") { setInView(true); return; } const observer = new IntersectionObserver( (entries) => { for (const entry of entries) { if (entry.isIntersecting) { setInView(true); observer.disconnect(); break; } } }, { threshold: 0.2, rootMargin: "0px 0px -10% 0px" }, ); observer.observe(node); return () => observer.disconnect(); }, []); return (
{children}
); }