UNPKG

@ionic/core

Version:
4 lines • 1.67 kB
/*! * (C) Ionic http://ionicframework.com - MIT License */ import{n as t,x as e}from"./p-Co7eql8D.js";import"./p-BpRUsN_W.js";import"./p-Dojwmvde.js";const o=o=>{if(void 0===t)return;let f,p,l,u=0;const d=o.getBoolean("animated",!0)&&o.getBoolean("rippleEffect",!0),v=new WeakMap,m=()=>{l&&clearTimeout(l),l=void 0,f&&(D(!1),f=void 0)},w=(t,o)=>{if(t&&t===f)return;l&&clearTimeout(l),l=void 0;const{x:i,y:r}=e(o);if(f){if(v.has(f))throw new Error("internal error");f.classList.contains(a)||T(f,i,r),D(!0)}if(t){const e=v.get(t);e&&(clearTimeout(e),v.delete(t)),t.classList.remove(a);const o=()=>{T(t,i,r),l=void 0};n(t)?o():l=setTimeout(o,c)}f=t},T=(t,e,o)=>{if(u=Date.now(),t.classList.add(a),!d)return;const i=r(t);null!==i&&(j(),p=i.addRipple(e,o))},j=()=>{void 0!==p&&(p.then((t=>t())),p=void 0)},D=t=>{j();const e=f;if(!e)return;const o=s-Date.now()+u;if(t&&o>0&&!n(e)){const t=setTimeout((()=>{e.classList.remove(a),v.delete(e)}),s);v.set(e,t)}else e.classList.remove(a)};t.addEventListener("ionGestureCaptured",m),t.addEventListener("pointerdown",(t=>{f||2===t.button||w(i(t),t)}),!0),t.addEventListener("pointerup",(t=>{w(void 0,t)}),!0),t.addEventListener("pointercancel",m,!0)},i=t=>{if(void 0===t.composedPath)return t.target.closest(".ion-activatable");{const e=t.composedPath();for(let t=0;t<e.length-2;t++){const o=e[t];if(!(o instanceof ShadowRoot)&&o.classList.contains("ion-activatable"))return o}}},n=t=>t.classList.contains("ion-activatable-instant"),r=t=>{if(t.shadowRoot){const e=t.shadowRoot.querySelector("ion-ripple-effect");if(e)return e}return t.querySelector("ion-ripple-effect")},a="ion-activated",c=100,s=150;export{o as startTapClick}