UNPKG

@zoff-tech/zt-bottom-drawer

Version:
2 lines 1.78 kB
import{r as t,d as i,h as s,H as e,e as n}from"./p-f6c816ce.js";import{inheritAttributes as r}from"@utils/helpers";import{g as o}from"./p-0b9b2444.js";const h=":host{display:block;object-fit:contain}img{display:block;width:100%;height:100%;object-fit:inherit;object-position:inherit}";const d=class{constructor(s){t(this,s);this.ionImgWillLoad=i(this,"ionImgWillLoad",7);this.ionImgDidLoad=i(this,"ionImgDidLoad",7);this.ionError=i(this,"ionError",7);this.inheritedAttributes={};this.onLoad=()=>{this.ionImgDidLoad.emit()};this.onError=()=>{this.ionError.emit()};this.loadSrc=undefined;this.loadError=undefined;this.alt=undefined;this.src=undefined}srcChanged(){this.addIO()}componentWillLoad(){this.inheritedAttributes=r(this.el,["draggable"])}componentDidLoad(){this.addIO()}addIO(){if(this.src===undefined){return}if(typeof window!=="undefined"&&"IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"isIntersecting"in window.IntersectionObserverEntry.prototype){this.removeIO();this.io=new IntersectionObserver((t=>{if(t[t.length-1].isIntersecting){this.load();this.removeIO()}}));this.io.observe(this.el)}else{setTimeout((()=>this.load()),200)}}load(){this.loadError=this.onError;this.loadSrc=this.src;this.ionImgWillLoad.emit()}removeIO(){if(this.io){this.io.disconnect();this.io=undefined}}render(){const{loadSrc:t,alt:i,onLoad:n,loadError:r,inheritedAttributes:h}=this;const{draggable:d}=h;return s(e,{class:o(this)},s("img",{decoding:"async",src:t,alt:i,onLoad:n,onError:r,part:"image",draggable:a(d)}))}get el(){return n(this)}static get watchers(){return{src:["srcChanged"]}}};const a=t=>{switch(t){case"true":return true;case"false":return false;default:return undefined}};d.style=h;export{d as ion_img}; //# sourceMappingURL=p-f4482e30.entry.js.map