%PDF- %PDF-
Direktori : /proc/self/root/var/www/html/src/Components/ |
Current File : //proc/self/root/var/www/html/src/Components/useInView.js |
import { useEffect, useRef, useState } from "react"; export const useInView = (ref, options) => { const [isIntersecting, setIsIntersecting] = useState(false); const observerRef = useRef(null); useEffect(() => { observerRef.current = new IntersectionObserver(([entry]) => { setIsIntersecting(entry.isIntersecting); }, options); }, []); useEffect(() => { observerRef.current.observe(ref.current); return () => { observerRef.current.disconnect(); }; }, [ref, options]); return isIntersecting; };