UNPKG

react-klasha

Version:

This is an reactJS library for implementing klasha payment gateway

1 lines 1.87 kB
import{r as registerInstance,e as createEvent,h,H as Host,i as getElement}from"./index-7a8b7a1c.js";import{b as getIonMode}from"./ionic-global-63a97a32.js";var imgCss=":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 Img=function(){function t(t){var i=this;registerInstance(this,t);this.ionImgWillLoad=createEvent(this,"ionImgWillLoad",7);this.ionImgDidLoad=createEvent(this,"ionImgDidLoad",7);this.ionError=createEvent(this,"ionError",7);this.onLoad=function(){i.ionImgDidLoad.emit()};this.onError=function(){i.ionError.emit()}}t.prototype.srcChanged=function(){this.addIO()};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[0].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(){return h(Host,{class:getIonMode(this)},h("img",{decoding:"async",src:this.loadSrc,alt:this.alt,onLoad:this.onLoad,onError:this.loadError,part:"image"}))};Object.defineProperty(t.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(t,"watchers",{get:function(){return{src:["srcChanged"]}},enumerable:false,configurable:true});return t}();Img.style=imgCss;export{Img as ion_img};