import{onMounted as m,watch as p,onBeforeUnmount as E}from"vue";const L=14/15;function T(f,c,u){let n=!1,s=0,t=null,o=null;const r=()=>{t&&(t.removeEventListener("touchmove",v),t.removeEventListener("touchend",l))},v=e=>{if(n){const d=Math.ceil(e.touches[0].pageY);let a=s-d;s=d,u(a)&&e.preventDefault(),clearInterval(o),o=setInterval(()=>{a*=L,(!u(a,!0)||Math.abs(a)<=.1)&&clearInterval(o)},16)}},l=()=>{n=!1,r()},i=e=>{r(),e.touches.length===1&&!n&&(n=!0,s=Math.ceil(e.touches[0].pageY),t=e.target,t.addEventListener("touchmove",v,{passive:!1}),t.addEventListener("touchend",l))},h=()=>{};m(()=>{document.addEventListener("touchmove",h,{passive:!1}),p(f,e=>{c.value.removeEventListener("touchstart",i),r(),clearInterval(o),e&&c.value.addEventListener("touchstart",i,{passive:!1})},{immediate:!0})}),E(()=>{document.removeEventListener("touchmove",h)})}export{T as default};
