UNPKG

radh-ui

Version:

Stencil Component Starter

1 lines 779 B
import{r as s,h as t,g as r}from"./p-1a9f3501.js";class i{constructor(t){s(this,t),this.onIntersection=async s=>{for(const t of s)t.isIntersecting&&(this.observer&&this.observer.disconnect(),t.target.getAttribute("data-src")&&(console.log(t.target.getAttribute("data-src")),t.target.setAttribute("src",t.target.getAttribute("data-src")),t.target.removeAttribute("data-src")))}}async componentDidLoad(){const s=this.el.shadowRoot.querySelector("img");this.time||(this.time=0),s&&setTimeout(()=>{this.observer=new IntersectionObserver(this.onIntersection,{rootMargin:"100px 0px"}),this.observer.observe(s)},this.time)}render(){return t("img",{"data-src":this.imgSrc,src:"assets/imgs/dummy-off.png"})}get el(){return r(this)}}i.style="img{max-width:100%}";export{i as radh_lazy_img}