index-fd3db2b1.js 2.8 KB

1
  1. import{d as O,ah as s,b as V,e as C,r as A,ao as P,a as M,o as R,k as j,ak as D,R as F,ba as G,i as H,bb as J,__tla as K}from"./index-4d37640d.js";import{E as N,__tla as Q}from"./el-image-viewer-71136349.js";let T,U=Promise.all([(()=>{try{return K}catch{}})(),(()=>{try{return Q}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),u=g,h=C(()=>{const n={...u};return delete n.show,n}),l=A(u.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,d=!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){d=!1,e.moveable=!1,delete e.pageX2,delete e.pageY2}function w(n){d=!0,n.touches.length===1&&d&&(c=n.touches[0].clientX,_=n.touches[0].clientY,x=c-a.offsetLeft,b=_-a.offsetTop)}function E(n){if(n.touches.length==1&&d){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(){P(()=>{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=N;return M(l)?(R(),j(o,D({key:0},M(h),{onClose:v}),null,16)):F("",!0)}}});let y=null;T=function(g){if(!G)return;const{urlList:m,initialIndex:f=0,infinite:u=!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=u,t.hideOnClickModal=h,t.appendToBody=l,t.zIndex=v,t.show=a,document.body.appendChild(c),y=H(z,t),J(y,c)}});export{U as __tla,T as c};