1 |
- System.register(["./index-legacy-a314c7dd.js","./index-legacy-dd79c724.js","./index-legacy-72dfb7ed.js"],(function(e,o){"use strict";var t,a,i,s,n,l,r,c,m,v,u,g,d,h,p,f,w,x,b,y,Z,P,X,Y,z,C,I,H,S,R,W,$,D,T,j,N,B,O,k,L,M,A;return{setters:[e=>{t=e.c,a=e.d,i=e.b5,s=e.n,n=e.x,l=e.u,r=e.r,c=e.e,m=e.w,v=e._,u=e.a,g=e.p,d=e.a0,h=e.aT,p=e.L,f=e.$,w=e.bg,x=e.bh,b=e.t,y=e.ab,Z=e.b,P=e.a5,X=e.m,Y=e.Z,z=e.y,C=e.bi,I=e.bj,H=e.z,S=e.h,R=e.ae,W=e.Q,$=e.H,D=e.I,T=e.a1,j=e.aG,N=e.ac,B=e.bk,O=e.bl,k=e.k},e=>{L=e.a,M=e.S},e=>{A=e.I}],execute:function(){const o=e=>Math.sqrt((e[0].clientX-e[1].clientX)**2+(e[0].clientY-e[1].clientY)**2),U=t("image-preview")[1];var q=a({props:{src:String,show:Boolean,active:Number,minZoom:i(s),maxZoom:i(s),rootWidth:i(Number),rootHeight:i(Number),disableZoom:Boolean},emits:["scale","close","longPress"],setup(e,{emit:t,slots:a}){const i=n({scale:1,moveX:0,moveY:0,moving:!1,zooming:!1,initializing:!1,imageRatio:0}),s=l(),b=r(),y=r(),Z=r(!1),P=r(!1);let X=0;const Y=c((()=>{const{scale:e,moveX:o,moveY:t,moving:a,zooming:s,initializing:n}=i,l={transitionDuration:s||a||n?"0s":".3s"};return(1!==e||P.value)&&(l.transform=`matrix(${e}, 0, 0, ${e}, ${o}, ${t})`),l})),z=c((()=>{if(i.imageRatio){const{rootWidth:o,rootHeight:t}=e,a=Z.value?t/i.imageRatio:o;return Math.max(0,(i.scale*a-o)/2)}return 0})),C=c((()=>{if(i.imageRatio){const{rootWidth:o,rootHeight:t}=e,a=Z.value?t:o*i.imageRatio;return Math.max(0,(i.scale*a-t)/2)}return 0})),I=(o,a)=>{var s;if((o=d(o,+e.minZoom,+e.maxZoom+1))!==i.scale){const n=o/i.scale;if(i.scale=o,a){const e=f(null==(s=b.value)?void 0:s.$el),o={x:.5*e.width,y:.5*e.height},t=i.moveX-(a.x-e.left-o.x)*(n-1),l=i.moveY-(a.y-e.top-o.y)*(n-1);i.moveX=d(t,-z.value,z.value),i.moveY=d(l,-C.value,C.value)}else i.moveX=0,i.moveY=P.value?X:0;t("scale",{scale:o,index:e.active})}},H=()=>{I(1)};let S,R,W,$,D,T,j,N,B=!1;const O=t=>{const{touches:a}=t;if(S=a.length,2===S&&e.disableZoom)return;const{offsetX:n}=s;s.start(t),R=i.moveX,W=i.moveY,N=Date.now(),B=!1,i.moving=1===S&&(1!==i.scale||P.value),i.zooming=2===S&&!n.value,i.zooming&&($=i.scale,D=o(a))},k=()=>{if(S>1)return;const{offsetX:e,offsetY:o}=s,a=Date.now()-N;e.value<w&&o.value<w&&(a<250?j?(clearTimeout(j),j=null,(()=>{const e=i.scale>1?1:2;I(e,2===e||P.value?{x:s.startX.value,y:s.startY.value}:void 0)})()):j=setTimeout((()=>{t("close"),j=null}),250):a>x&&t("longPress"))},M=o=>{let t=!1;if((i.moving||i.zooming)&&(t=!0,i.moving&&R===i.moveX&&W===i.moveY&&(t=!1),!o.touches.length)){i.zooming&&(i.moveX=d(i.moveX,-z.value,z.value),i.moveY=d(i.moveY,-C.value,C.value),i.zooming=!1),i.moving=!1,R=0,W=0,$=1,i.scale<1&&H();const o=+e.maxZoom;i.scale>o&&I(o,T)}g(o,t),k(),s.reset()},q=()=>{const{rootWidth:o,rootHeight:t}=e,a=t/o,{imageRatio:s}=i;Z.value=i.imageRatio>a&&s<2.6,P.value=i.imageRatio>a&&s>=2.6,P.value&&(X=(s*o-t)/2,i.moveY=X,i.initializing=!0,h((()=>{i.initializing=!1}))),H()},E=e=>{const{naturalWidth:o,naturalHeight:t}=e.target;i.imageRatio=t/o,q()};return m((()=>e.active),H),m((()=>e.show),(e=>{e||H()})),m((()=>[e.rootWidth,e.rootHeight]),q),v("touchmove",(e=>{const{touches:t}=e;if(s.move(e),i.moving){const{deltaX:o,deltaY:t}=s,a=o.value+R,n=t.value+W;if((a>z.value||a<-z.value)&&!B&&s.isHorizontal())return void(i.moving=!1);B=!0,g(e,!0),i.moveX=d(a,-z.value,z.value),i.moveY=d(n,-C.value,C.value)}if(i.zooming&&(g(e,!0),2===t.length)){const e=o(t),a=$*e/D;T=(e=>({x:(e[0].clientX+e[1].clientX)/2,y:(e[0].clientY+e[1].clientY)/2}))(t),I(a,T)}}),{target:c((()=>{var e;return null==(e=y.value)?void 0:e.$el}))}),()=>{const o={loading:()=>u(p,{type:"spinner"},null)};return u(L,{ref:y,class:U("swipe-item"),onTouchstartPassive:O,onTouchend:M,onTouchcancel:M},{default:()=>[a.image?u("div",{class:U("image-wrap")},[a.image({src:e.src})]):u(A,{ref:b,src:e.src,fit:"contain",class:U("image",{vertical:Z.value}),style:Y.value,onLoad:E},o)]})}}});const[E,F]=t("image-preview"),G=["show","teleport","transition","overlayStyle","closeOnPopstate"],Q={show:Boolean,loop:b,images:y(),minZoom:Z(1/3),maxZoom:Z(3),overlay:b,closeable:Boolean,showIndex:b,className:P,closeIcon:X("clear"),transition:String,beforeClose:Function,overlayClass:P,overlayStyle:Object,swipeDuration:Z(300),startPosition:Z(0),showIndicators:Boolean,closeOnPopstate:b,closeIconPosition:X("top-right"),teleport:[String,Object]};var _=a({name:E,props:Q,emits:["scale","close","closed","change","longPress","update:show"],setup(e,{emit:o,slots:t}){const a=r(),i=n({active:0,rootWidth:0,rootHeight:0,disableZoom:!1}),s=()=>{if(a.value){const e=f(a.value.$el);i.rootWidth=e.width,i.rootHeight=e.height,a.value.resize()}},l=e=>o("scale",e),c=e=>o("update:show",e),v=()=>{T(e.beforeClose,{args:[i.active],done:()=>c(!1)})},g=e=>{e!==i.active&&(i.active=e,o("change",e))},d=()=>{if(e.showIndex)return u("div",{class:F("index")},[t.index?t.index({index:i.active}):`${i.active+1} / ${e.images.length}`])},h=()=>{if(t.cover)return u("div",{class:F("cover")},[t.cover()])},p=()=>{i.disableZoom=!0},w=()=>{i.disableZoom=!1},x=()=>{if(e.closeable)return u(D,{role:"button",name:e.closeIcon,class:[F("close-icon",e.closeIconPosition),$],onClick:v},null)},b=()=>o("closed"),y=(e,o)=>{var t;return null==(t=a.value)?void 0:t.swipeTo(e,o)};return Y({swipeTo:y}),z(s),m([C,I],s),m((()=>e.startPosition),(e=>g(+e))),m((()=>e.show),(t=>{const{images:a,startPosition:n}=e;t?(g(+n),H((()=>{s(),y(+n,{immediate:!0})}))):o("close",{index:i.active,url:a[i.active]})})),()=>u(W,S({class:[F(),e.className],overlayClass:[F("overlay"),e.overlayClass],onClosed:b,"onUpdate:show":c},R(e,G)),{default:()=>[x(),u(M,{ref:a,lazyRender:!0,loop:e.loop,class:F("swipe"),duration:e.swipeDuration,initialSwipe:e.startPosition,showIndicators:e.showIndicators,indicatorColor:"white",onChange:g,onDragEnd:w,onDragStart:p},{default:()=>[e.images.map(((a,s)=>u(q,{src:a,show:e.show,active:i.active,maxZoom:e.maxZoom,minZoom:e.minZoom,rootWidth:i.rootWidth,rootHeight:i.rootHeight,disableZoom:i.disableZoom,onScale:l,onClose:v,onLongPress:()=>o("longPress",{index:s})},{image:t.image})))]}),d(),h()]})}});let J;const K={loop:!0,images:[],maxZoom:3,minZoom:1/3,onScale:void 0,onClose:void 0,onChange:void 0,teleport:"body",className:"",showIndex:!0,closeable:!1,closeIcon:"clear",transition:void 0,beforeClose:void 0,overlayStyle:void 0,overlayClass:void 0,startPosition:0,swipeDuration:300,showIndicators:!1,closeOnPopstate:!0,closeIconPosition:"top-right"};e("s",((e,o=0)=>{if(j)return J||({instance:J}=B({setup(){const{state:e,toggle:o}=O(),t=()=>{e.images=[]};return()=>u(_,S(e,{onClosed:t,"onUpdate:show":o}),null)}})),e=Array.isArray(e)?{images:e,startPosition:o}:e,J.open(N({},K,e)),J})),k(_)}}}));
|