UNPKG

@gravity-ui/uikit

Version:

Gravity UI base styling and components

16 lines (15 loc) 548 B
import * as React from 'react'; export const useIntersection = ({ element, options, onIntersect }) => { React.useEffect(() => { const observer = new IntersectionObserver(([entry]) => { if (entry.isIntersecting) { onIntersect?.(); } }, options); if (element) { observer.observe(element); } return () => (element === null ? undefined : observer.unobserve(element)); }, [element, options, onIntersect]); }; //# sourceMappingURL=useIntersection.js.map