index-b59955b6.js 2.8 KB

1
  1. import{d as O,ah as s,b as V,e as C,r as j,ao as A,a as M,o as P,j as D,ak as F,l as G,bc as H,i as J,bd as K,__tla as N}from"./index-1e808f2e.js";import{E as Q,__tla as R}from"./el-image-viewer-dddb6285.js";let T,U=Promise.all([(()=>{try{return N}catch{}})(),(()=>{try{return R}catch{}})()]).then(async()=>{const z=O({name:"ImageViewer",__name:"ImageViewer",props:{urlList:{type:Array,default:()=>[]},zIndex:s.number.def(200),initialIndex:s.number.def(0),infinite:s.bool.def(!0),hideOnClickModal:s.bool.def(!1),appendToBody:s.bool.def(!1),show:s.bool.def(!1)},setup(g){const m=V(),f=C(()=>m.getMobile),d=g,h=C(()=>{const n={...d};return delete n.show,n}),l=j(d.show);l.value&&I();const v=()=>{l.value=!1,I()};let a=document.querySelector(".el-image-viewer__img"),t=document.querySelector(".el-image-viewer__wrapper"),c=0,_=0,x=0,b=0,u=!0;const e={scale:1};function L(n){var r=n.touches,o=r[0],i=r[1];n&&(e.pageX=o.pageX,e.pageY=o.pageY,e.moveable=!0,i&&(e.pageX2=i.pageX,e.pageY2=i.pageY),e.originScale=e.scale||1)}function X(n){if(e.moveable){var r=n.touches,o=r[0],i=r[1];if(i){e.pageX2||(e.pageX2=i.pageX),e.pageY2||(e.pageY2=i.pageY);var S=function(k,q){return Math.hypot(q.x-k.x,q.y-k.y)},B=S({x:o.pageX,y:o.pageY},{x:i.pageX,y:i.pageY})/S({x:e.pageX,y:e.pageY},{x:e.pageX2,y:e.pageY2}),p=e.originScale*B;p>3&&(p=3),e.scale=p,a.style.transform="scale("+p+")",a.style.transition="transform .3s"}}}function Y(n){u=!1,e.moveable=!1,delete e.pageX2,delete e.pageY2}function w(n){u=!0,n.touches.length===1&&u&&(c=n.touches[0].clientX,_=n.touches[0].clientY,x=c-a.offsetLeft,b=_-a.offsetTop)}function E(n){if(n.touches.length==1&&u){const r=n.touches[0].clientX,o=n.touches[0].clientY;a.style.position!="fixed"&&(a.style.position="fixed"),a.style.left=r-x+"px",a.style.top=o-b+"px"}}function I(){A(()=>{a=document.querySelector(".el-image-viewer__img"),t=document.querySelector(".el-image-viewer__wrapper"),l.value?(f&&(document.querySelector(".el-image-viewer__actions").style.display="none"),t.addEventListener("touchstart",L),t.addEventListener("touchmove",X),t.addEventListener("touchend",Y),t.addEventListener("touchcancel",function(){e.moveable=!1,delete e.pageX2,delete e.pageY2}),a.addEventListener("touchstart",w),a.addEventListener("touchmove",E)):(t&&(t.removeEventListener("touchstart",L),t.removeEventListener("touchmove",X),t.removeEventListener("touchend",Y)),a&&(a.removeEventListener("touchstart",w),a.removeEventListener("touchmove",E)))})}return(n,r)=>{const o=Q;return M(l)?(P(),D(o,F({key:0},M(h),{onClose:v}),null,16)):G("",!0)}}});let y=null;T=function(g){if(!H)return;const{urlList:m,initialIndex:f=0,infinite:d=!0,hideOnClickModal:h=!1,appendToBody:l=!1,zIndex:v=2e3,show:a=!0}=g,t={},c=document.createElement("div");t.urlList=m,t.initialIndex=f,t.infinite=d,t.hideOnClickModal=h,t.appendToBody=l,t.zIndex=v,t.show=a,document.body.appendChild(c),y=J(z,t),K(y,c)}});export{U as __tla,T as c};