vanilla-lazyload
Version:
LazyLoad is a lightweight (2.4 kB) and flexible script that speeds up your web application by deferring the loading of your below-the-fold images, videos and iframes to when they will enter the viewport. It's written in plain "vanilla" JavaScript, it leve
2 lines (1 loc) • 600 B
JavaScript
import{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};