import{r as registerInstance,c as createEvent,h,H as Host}from"./index-c948674f.js";import{c as classnames}from"./index-394db4c1.js";var indexCss='img[src=""]{opacity:0}taro-image-core{display:inline-block;overflow:hidden;position:relative;width:auto;height:auto;font-size:0}.taro-img.taro-img__widthfix{height:100%}.taro-img__mode-scaletofill{width:100%;height:100%}.taro-img__mode-aspectfit{max-width:100%;max-height:100%}.taro-img__mode-aspectfill{position:absolute;left:50%;top:50%;-webkit-transform:translate(-50%, -50%);transform:translate(-50%, -50%)}.taro-img__mode-aspectfill--width{min-width:100%;height:100%}.taro-img__mode-aspectfill--height{width:100%;min-height:100%}.taro-img__mode-widthfix{width:100%}.taro-img__mode-heightfix{height:100%}.taro-img__mode-top{width:100%}.taro-img__mode-bottom{position:absolute;bottom:0;width:100%}.taro-img__mode-left{height:100%}.taro-img__mode-right{position:absolute;right:0;height:100%}.taro-img__mode-topright{position:absolute;right:0}.taro-img__mode-bottomleft{position:absolute;bottom:0}.taro-img__mode-bottomright{position:absolute;right:0;bottom:0}';import("./intersection-observer-8e4c7135.js");var Image=function(){function t(t){registerInstance(this,t);this.onLoad=createEvent(this,"load",7);this.onError=createEvent(this,"error",7);this.src=undefined;this.mode="scaleToFill";this.lazyLoad=false;this.nativeProps={};this.aspectFillMode="width"}t.prototype.componentDidLoad=function(){var t=this;if(!this.lazyLoad)return;var i=new IntersectionObserver((function(o){if(o[o.length-1].isIntersecting){i.unobserve(t.imgRef);t.imgRef.src=t.src}}),{rootMargin:"300px 0px"});i.observe(this.imgRef)};t.prototype.imageOnLoad=function(){var t=this.imgRef,i=t.width,o=t.height,e=t.naturalWidth,r=t.naturalHeight;this.onLoad.emit({width:i,height:o});this.aspectFillMode=e>r?"width":"height"};t.prototype.imageOnError=function(t){this.onError.emit(t)};t.prototype.render=function(){var t;var i=this;var o=this,e=o.src,r=o.mode,a=r===void 0?"scaleToFill":r,s=o.lazyLoad,n=s===void 0?false:s,m=o.aspectFillMode,d=m===void 0?"width":m,g=o.imageOnLoad,c=o.imageOnError,l=o.nativeProps;var f=classnames({"taro-img__widthfix":a==="widthFix"});var p=classnames("taro-img__mode-".concat(a.toLowerCase().replace(/\s/g,"")),(t={},t["taro-img__mode-aspectfill--".concat(d)]=a==="aspectFill",t));return h(Host,{class:f},n?h("img",Object.assign({ref:function(t){return i.imgRef=t},class:p,onLoad:g.bind(this),onError:c.bind(this)},l)):h("img",Object.assign({ref:function(t){return i.imgRef=t},class:p,src:e,onLoad:g.bind(this),onError:c.bind(this)},l)))};return t}();Image.style=indexCss;export{Image as taro_image_core};
//# sourceMappingURL=taro-image-core.entry.js.map