"use client" import { useEffect, useRef, useState } from "react" export function useIntersection(threshold = 0.2) { const ref = useRef(null) const [isVisible, setIsVisible] = useState(false) useEffect(() => { const el = ref.current if (!el) return const observer = new IntersectionObserver( ([entry]) => { if (entry.isIntersecting) { setIsVisible(true) } }, { threshold } ) observer.observe(el) return () => observer.disconnect() }, [threshold]) return { ref, isVisible } }