UNPKG

@ionic/core

Version:
4 lines 2.44 kB
/*! * (C) Ionic http://ionicframework.com - MIT License */ System.register(["./p-f11a9436.system.js","./p-455cd7cc.system.js","./p-f201b53a.system.js"],(function(t){"use strict";var i,n,e,s,r,o,c;return{setters:[function(t){i=t.r;n=t.c;e=t.h;s=t.e;r=t.f},function(t){o=t.h},function(t){c=t.b}],execute:function(){var f=":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}";var u=f;var a=t("ion_img",function(){function t(t){var e=this;i(this,t);this.ionImgWillLoad=n(this,"ionImgWillLoad",7);this.ionImgDidLoad=n(this,"ionImgDidLoad",7);this.ionError=n(this,"ionError",7);this.inheritedAttributes={};this.onLoad=function(){e.ionImgDidLoad.emit()};this.onError=function(){e.ionError.emit()};this.loadSrc=undefined;this.loadError=undefined;this.alt=undefined;this.src=undefined}t.prototype.srcChanged=function(){this.addIO()};t.prototype.componentWillLoad=function(){this.inheritedAttributes=o(this.el,["draggable"])};t.prototype.componentDidLoad=function(){this.addIO()};t.prototype.addIO=function(){var t=this;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((function(i){if(i[i.length-1].isIntersecting){t.load();t.removeIO()}}));this.io.observe(this.el)}else{setTimeout((function(){return t.load()}),200)}};t.prototype.load=function(){this.loadError=this.onError;this.loadSrc=this.src;this.ionImgWillLoad.emit()};t.prototype.removeIO=function(){if(this.io){this.io.disconnect();this.io=undefined}};t.prototype.render=function(){var t=this,i=t.loadSrc,n=t.alt,r=t.onLoad,o=t.loadError,f=t.inheritedAttributes;var u=f.draggable;return e(s,{key:"da600442894427dee1974a28e545613afac69fca",class:c(this)},e("img",{key:"16df0c7069af86c0fa7ce5af598bc0f63b4eb71a",decoding:"async",src:i,alt:n,onLoad:r,onError:o,part:"image",draggable:h(u)}))};Object.defineProperty(t.prototype,"el",{get:function(){return r(this)},enumerable:false,configurable:true});Object.defineProperty(t,"watchers",{get:function(){return{src:["srcChanged"]}},enumerable:false,configurable:true});return t}());var h=function(t){switch(t){case"true":return true;case"false":return false;default:return undefined}};a.style=u}}}));