You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2 lines
1.2 KiB

import{by as i}from"./index-f4658ae7.js";const f=20;function a(s,o,e,t,h,r){const c={x:0,y:0};return t.x<f&&(c.x=f),t.x>s.width-h&&(c.x=s.width-h-f),t.y+e+r>s.height&&(c.y=t.y-r-e),c.x==0&&(c.x=t.x-(h-o)/2,c.x<0&&(c.x=f)),c.y==0&&(c.y=t.y+e+f),(c.y<0||c.y+r>s.height)&&(c.y=(s.height-r)/2,c.x=t.x>s.width/2?t.x-h-f:t.x+o+f),c}const E=s=>new Promise((o,e)=>{const t=document.createElement("img");t.onerror=()=>{e(),t.remove()},t.onload=()=>{o(),t.remove()},t.src=s}),X=(s,o)=>{i()&&s.addEventListener("touchstart",function(e){e.preventDefault();const{tx:t,ty:h}=o.translate(),r=e.touches[0].clientX,c=e.touches[0].clientY;let l=0;document.addEventListener("touchmove",x),e.touches.length==2&&(l=Math.hypot(e.touches[1].clientX-r,e.touches[1].clientY-c)),document.addEventListener("touchend",function(){document.removeEventListener("touchmove",x)});function x(u){if(u.preventDefault(),u.touches.length==2){const m=Math.hypot(u.touches[1].clientX-u.touches[0].clientX,u.touches[1].clientY-u.touches[0].clientY);if(l!=0){const n=m/l;o.zoomTo(n)}}else{const m=t+u.touches[0].clientX-r,n=h+u.touches[0].clientY-c;o.translate(m,n)}}})};export{X as addMobileSupport,a as calcPanelPosition,E as checkImg};