UNPKG

@tindtechnologies/universalviewer

Version:

The Universal Viewer is a community-developed open source project on a mission to help you share your 📚📜📰📽️📻🗿 with the 🌎

2 lines (1 loc) 1.62 kB
import{a as r,e as n,f as s,i as e,l as c,o as a}from"./chunk-VNJCZCB4.js";import"./chunk-L67DAW3A.js";var d=function(){function t(i){var o=this;r(this,i),this.onLoad=function(){o.ionImgDidLoad.emit()},this.onError=function(){o.ionError.emit()},this.ionImgWillLoad=e(this,"ionImgWillLoad",7),this.ionImgDidLoad=e(this,"ionImgDidLoad",7),this.ionError=e(this,"ionError",7)}return t.prototype.srcChanged=function(){this.addIO()},t.prototype.componentDidLoad=function(){this.addIO()},t.prototype.addIO=function(){var i=this;this.src!==void 0&&("IntersectionObserver"in window?(this.removeIO(),this.io=new IntersectionObserver(function(o){o[0].isIntersecting&&(i.load(),i.removeIO())}),this.io.observe(this.el)):setTimeout(function(){return i.load()},200))},t.prototype.load=function(){this.loadError=this.onError,this.loadSrc=this.src,this.ionImgWillLoad.emit()},t.prototype.removeIO=function(){this.io&&(this.io.disconnect(),this.io=void 0)},t.prototype.render=function(){return n(s,{class:a(this)},n("img",{decoding:"async",src:this.loadSrc,alt:this.alt,onLoad:this.onLoad,onError:this.loadError}))},Object.defineProperty(t.prototype,"el",{get:function(){return c(this)},enumerable:!0,configurable:!0}),Object.defineProperty(t,"watchers",{get:function(){return{src:["srcChanged"]}},enumerable:!0,configurable:!0}),Object.defineProperty(t,"style",{get:function(){return":host{-o-object-fit:contain;object-fit:contain}:host,img{display:block}img{width:100%;height:100%;-o-object-fit:inherit;object-fit:inherit;-o-object-position:inherit;object-position:inherit}"},enumerable:!0,configurable:!0}),t}();export{d as ion_img};