UNPKG

@ionic/core

Version:
1 lines 1.89 kB
import{b as t,k as e}from"./chunk-6d7d2f8c.js";function n(n,r){let d,l,u,f,v=10*-a,p=0;const m=r.getBoolean("animated",!0)&&r.getBoolean("rippleEffect",!0),L=new WeakMap;function h(e){v=t(e),g(e)}function E(){clearTimeout(f),f=void 0,l&&(b(!1),l=void 0)}function w(t){l||void 0!==d&&null!==d.parentElement||(d=void 0,S(function(t){if(!t.composedPath)return t.target.closest(".ion-activatable");{const e=t.composedPath();for(let t=0;t<e.length-2;t++){const n=e[t];if(n.classList&&n.classList.contains("ion-activatable"))return n}}}(t),t))}function g(t){S(void 0,t)}function S(t,n){if(t&&t===l)return;clearTimeout(f),f=void 0;const{x:c,y:a}=e(n);if(l){if(L.has(l))throw new Error("internal error");l.classList.contains(i)||T(l,c,a),b(!0)}if(t){const e=L.get(t);e&&(clearTimeout(e),L.delete(t));const n=o(t)?0:s;t.classList.remove(i),f=setTimeout(()=>{T(t,c,a),f=void 0},n)}l=t}function T(t,e,n){p=Date.now(),t.classList.add(i);const o=m&&function(t){if(t.shadowRoot){const e=t.shadowRoot.querySelector("ion-ripple-effect");if(e)return e}return t.querySelector("ion-ripple-effect")}(t);o&&o.addRipple&&(u=o.addRipple(e,n))}function b(t){void 0!==u&&u.then(t=>t());const e=l;if(!e)return;const n=c-Date.now()+p;if(t&&n>0&&!o(e)){const t=setTimeout(()=>{e.classList.remove(i),L.delete(e)},c);L.set(e,t)}else e.classList.remove(i)}n.addEventListener("ionScrollStart",t=>{d=t.target,E()}),n.addEventListener("ionScrollEnd",()=>{d=void 0}),n.addEventListener("ionGestureCaptured",E),n.addEventListener("touchstart",function(e){v=t(e),w(e)},!0),n.addEventListener("touchcancel",h,!0),n.addEventListener("touchend",h,!0),n.addEventListener("mousedown",function(e){const n=t(e)-a;v<n&&w(e)},!0),n.addEventListener("mouseup",function(e){const n=t(e)-a;v<n&&g(e)},!0)}function o(t){return t.classList.contains("ion-activatable-instant")}const i="activated",s=200,c=200,a=2500;export{n as startTapClick};