UNPKG

@guruhotel/aura-hooks

Version:

🪝 Hooks library designed by the Guruhotel team for Aura UI

1 lines 368 B
import{useCallback as r,useRef as n,useState as e}from"react";export function useIntersection(t){const[o,u]=e(null),l=n();return[r((r=>{l.current&&(l.current.disconnect(),l.current=void 0),null!==r?(l.current=new IntersectionObserver((([r])=>{u(r)}),t),l.current.observe(r)):u(null)}),[null==t?void 0:t.rootMargin,null==t?void 0:t.root,null==t?void 0:t.threshold]),o]}