ll-package
Version:
2 lines (1 loc) • 966 B
JavaScript
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("vue"),E=14/15;function M(m,c,l){let n=!1,s=0,t=null,o=null;const a=()=>{t&&(t.removeEventListener("touchmove",v),t.removeEventListener("touchend",i))},v=e=>{if(n){const f=Math.ceil(e.touches[0].pageY);let u=s-f;s=f,l(u)&&e.preventDefault(),clearInterval(o),o=setInterval(()=>{u*=E,(!l(u,!0)||Math.abs(u)<=.1)&&clearInterval(o)},16)}},i=()=>{n=!1,a()},h=e=>{a(),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",i))},d=()=>{};r.onMounted(()=>{document.addEventListener("touchmove",d,{passive:!1}),r.watch(m,e=>{c.value.removeEventListener("touchstart",h),a(),clearInterval(o),e&&c.value.addEventListener("touchstart",h,{passive:!1})},{immediate:!0})}),r.onBeforeUnmount(()=>{document.removeEventListener("touchmove",d)})}exports.default=M;
;