"use client"; import { useRef, useState, useEffect, ReactNode } from "react"; interface FadeInProps { children: ReactNode; delay?: number; className?: string; } export function FadeIn({ children, delay = 0, className = "" }: FadeInProps) { const ref = useRef(null); const [visible, setVisible] = useState(false); useEffect(() => { const el = ref.current; if (!el) return; const obs = new IntersectionObserver( ([entry]) => { if (entry.isIntersecting) { setVisible(true); obs.unobserve(el); } }, { threshold: 0.15 } ); obs.observe(el); return () => obs.disconnect(); }, []); return (
{children}
); }