@ionic/core
Version:
Base components for Ionic
4 lines • 2.47 kB
JavaScript
/*!
* (C) Ionic http://ionicframework.com - MIT License
*/
import{d as t,H as i,i as e,p as s,h as o,f as n,t as r}from"./p-Ct2aBEue.js";import{j as a}from"./p-B4IBdPVJ.js";import{b as h}from"./p-HthJZjZ6.js";const c=t(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.ionImgWillLoad=e(this,"ionImgWillLoad",7),this.ionImgDidLoad=e(this,"ionImgDidLoad",7),this.ionError=e(this,"ionError",7),this.inheritedAttributes={},this.onLoad=()=>{this.ionImgDidLoad.emit()},this.onError=()=>{this.ionError.emit()}}srcChanged(){this.addIO()}componentWillLoad(){this.inheritedAttributes=a(this.el,["draggable"])}componentDidLoad(){s('[ion-img] - This component is deprecated and will be removed in Ionic v10. Use a native <img> with the loading="lazy" attribute instead.',this.el),this.addIO()}disconnectedCallback(){this.loadTimeout&&clearTimeout(this.loadTimeout)}addIO(){this.loadTimeout&&(clearTimeout(this.loadTimeout),this.loadTimeout=void 0),void 0!==this.src&&("undefined"!=typeof window&&"IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"isIntersecting"in window.IntersectionObserverEntry.prototype?(this.removeIO(),this.io=new IntersectionObserver((t=>{t[t.length-1].isIntersecting&&(this.load(),this.removeIO())})),this.io.observe(this.el)):this.loadTimeout=setTimeout((()=>this.load()),200))}load(){this.loadError=this.onError,this.loadSrc=this.src,this.ionImgWillLoad.emit()}removeIO(){this.io&&(this.io.disconnect(),this.io=void 0)}render(){const{loadSrc:t,alt:i,onLoad:e,loadError:s,inheritedAttributes:r}=this,{draggable:a}=r;return o(n,{key:"57bfb44d9850381fe7b6fcf0c9019b03f7ef86ec",class:h(this)},o("img",{key:"888ec06a266fa2751fc0147ede6a567f4e2b29a6",decoding:"async",src:t,alt:i,onLoad:e,onError:s,part:"image",draggable:d(a)}))}get el(){return this}static get watchers(){return{src:[{srcChanged:0}]}}static get style(){return":host{display:block;-o-object-fit:contain;object-fit:contain}img{display:block;width:100%;height:100%;-o-object-fit:inherit;object-fit:inherit;-o-object-position:inherit;object-position:inherit}"}},[1,"ion-img",{alt:[1],src:[1],loadSrc:[32],loadError:[32]},void 0,{src:[{srcChanged:0}]}]),d=t=>{switch(t){case"true":return!0;case"false":return!1;default:return}},l=c,m=function(){"undefined"!=typeof customElements&&["ion-img"].forEach((t=>{"ion-img"===t&&(customElements.get(r(t))||customElements.define(r(t),c))}))};export{l as IonImg,m as defineCustomElement}