UNPKG

600 BJavaScriptView Raw
1import{onEnter as r,onExit as e}from"./intersectionHandlers.js";import{shouldUseNative as o}from"./native.js";import{resetObserver as t}from"./unobserve.js";const n=r=>r.isIntersecting||r.intersectionRatio>0,s=(r,e)=>{e.forEach((e=>{r.observe(e)}))},i=(r,e)=>{t(r),s(r,e)},a=(t,s)=>{o(t)||(s._observer=new IntersectionObserver((o=>{((o,t,s)=>{o.forEach((o=>n(o)?r(o.target,o,t,s):e(o.target,o,t,s)))})(o,t,s)}),(r=>({root:r.container===document?null:r.container,rootMargin:r.thresholds||r.threshold+"px"}))(t)))};export{n as isIntersecting,s as observeElements,a as setObserver,i as updateObserver};