1 |
- import{d as z,af as r,b as B,e as C,r as O,am as V,a as M,o as j,j as A,ai as D,l as F,ba as G,i as H,bb as J}from"./index-34852970.js";import{E as K}from"./el-image-viewer-619778cc.js";const N=z({name:"ImageViewer",__name:"ImageViewer",props:{urlList:{type:Array,default:()=>[]},zIndex:r.number.def(200),initialIndex:r.number.def(0),infinite:r.bool.def(!0),hideOnClickModal:r.bool.def(!1),appendToBody:r.bool.def(!1),show:r.bool.def(!1)},setup(g){const m=B(),f=C(()=>m.getMobile),d=g,v=C(()=>{const o={...d};return delete o.show,o}),l=O(d.show);console.log(l.value),l.value&&_();const h=()=>{l.value=!1,_()};let n=document.querySelector(".el-image-viewer__img"),t=document.querySelector(".el-image-viewer__wrapper"),c=0,y=0,x=0,b=0,u=!0;const e={scale:1};function L(o){var s=o.touches,a=s[0],i=s[1];o&&(e.pageX=a.pageX,e.pageY=a.pageY,e.moveable=!0,i&&(e.pageX2=i.pageX,e.pageY2=i.pageY),e.originScale=e.scale||1)}function X(o){if(e.moveable){var s=o.touches,a=s[0],i=s[1];if(i){e.pageX2||(e.pageX2=i.pageX),e.pageY2||(e.pageY2=i.pageY);var I=function(S,q){return Math.hypot(q.x-S.x,q.y-S.y)},T=I({x:a.pageX,y:a.pageY},{x:i.pageX,y:i.pageY})/I({x:e.pageX,y:e.pageY},{x:e.pageX2,y:e.pageY2}),p=e.originScale*T;p>3&&(p=3),e.scale=p,n.style.transform="scale("+p+")",n.style.transition="transform .3s"}}}function Y(o){u=!1,e.moveable=!1,delete e.pageX2,delete e.pageY2}function w(o){u=!0,o.touches.length===1&&u&&(c=o.touches[0].clientX,y=o.touches[0].clientY,x=c-n.offsetLeft,b=y-n.offsetTop)}function E(o){if(o.touches.length==1&&u){const s=o.touches[0].clientX,a=o.touches[0].clientY;n.style.position!="fixed"&&(n.style.position="fixed"),n.style.left=s-x+"px",n.style.top=a-b+"px"}}function _(){console.log("\u56FE\u7247\u663E\u793A\u9690\u85CF\u5904\u7406"),V(()=>{n=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}),n.addEventListener("touchstart",w),n.addEventListener("touchmove",E)):(t&&(t.removeEventListener("touchstart",L),t.removeEventListener("touchmove",X),t.removeEventListener("touchend",Y)),n&&(n.removeEventListener("touchstart",w),n.removeEventListener("touchmove",E)))})}return(o,s)=>{const a=K;return M(l)?(j(),A(a,D({key:0},M(v),{onClose:h}),null,16)):F("",!0)}}});let k=null;function P(g){if(!G)return;const{urlList:m,initialIndex:f=0,infinite:d=!0,hideOnClickModal:v=!1,appendToBody:l=!1,zIndex:h=2e3,show:n=!0}=g,t={},c=document.createElement("div");t.urlList=m,t.initialIndex=f,t.infinite=d,t.hideOnClickModal=v,t.appendToBody=l,t.zIndex=h,t.show=n,document.body.appendChild(c),k=H(N,t),J(k,c)}export{P as c};
|