"use client"; import { useEffect } from "react"; // Fades blocks in as they scroll into view. Only blocks that start below the fold are hidden, so nothing on the // first screen flickers, and without JavaScript everything simply shows. export function RevealOnScroll({ selector }: { selector: string }) { useEffect(() => { if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) return; const els = Array.from(document.querySelectorAll(selector)).filter( (el) => el.getBoundingClientRect().top > window.innerHeight ); const io = new IntersectionObserver( (entries) => entries.forEach((e) => { if (!e.isIntersecting) return; e.target.classList.add("in"); io.unobserve(e.target); }), { rootMargin: "0px 0px -8% 0px" } ); els.forEach((el) => { el.classList.add("reveal"); io.observe(el); }); return () => io.disconnect(); }, [selector]); return null; }