import { useEffect, useRef, useState } from 'react'; export function useScrollAnimation(threshold = 0.1) { const [isVisible, setIsVisible] = useState(false); const ref = useRef(null); useEffect(() => { const observer = new IntersectionObserver( ([entry]) => { if (entry.isIntersecting) { setIsVisible(true); observer.unobserve(entry.target); } }, { threshold } ); if (ref.current) { observer.observe(ref.current); } return () => observer.disconnect(); }, [threshold]); return { ref, isVisible }; }