@ionic/core
Version:
Base components for Ionic
4 lines • 1.67 kB
JavaScript
/*!
* (C) Ionic http://ionicframework.com - MIT License
*/
import{d as t}from"./p-ZjP4CjeZ.js";import{q as e}from"./p-Do-uqmtX.js";import"./p-B_U9CtaY.js";const o=o=>{if(void 0===t)return;let f,p,u,l=0;const d=o.getBoolean("animated",!0)&&o.getBoolean("rippleEffect",!0),v=new WeakMap,m=()=>{u&&clearTimeout(u),u=void 0,f&&(b(!1),f=void 0)},j=(t,o)=>{if(t&&t===f)return;u&&clearTimeout(u),u=void 0;const{x:i,y:r}=e(o);if(f){if(v.has(f))throw new Error("internal error");f.classList.contains(a)||w(f,i,r),b(!0)}if(t){const e=v.get(t);e&&(clearTimeout(e),v.delete(t)),t.classList.remove(a);const o=()=>{w(t,i,r),u=void 0};n(t)?o():u=setTimeout(o,c)}f=t},w=(t,e,o)=>{if(l=Date.now(),t.classList.add(a),!d)return;const i=r(t);null!==i&&(T(),p=i.addRipple(e,o))},T=()=>{void 0!==p&&(p.then((t=>t())),p=void 0)},b=t=>{T();const e=f;if(!e)return;const o=s-Date.now()+l;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||j(i(t),t)}),!0),t.addEventListener("pointerup",(t=>{j(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}