xtendui
Version:
Xtend UI is a powerful frontend library of Tailwind CSS components enhanced by vanilla js. It helps you build interfaces with advanced interactions and animations.
3 lines • 3.47 kB
JavaScript
/*! For license information please see 792.min.js.LICENSE.txt */
;(globalThis.webpackChunkxtendui=globalThis.webpackChunkxtendui||[]).push([[792],{7792:(t,e,n)=>{n.r(e),n.d(e,{RippleInit:()=>i});var o=n(5498);class i{_init(){this._initVars(),this._initLogic()}_initVars(){const t=this;t._optionsDefault=o.Xt.merge([t.constructor.optionsDefault,o.Xt.options[t.componentName]]),t._optionsInitial=t.options=o.Xt.merge([t._optionsDefault,t._optionsCustom])}_initLogic(){const t=this,e=t.options;t.ns=t.ns??o.Xt.uniqueId(),t.enable(),o.Xt._initMatches({self:t,optionsInitial:t._optionsInitial}),t.initial=!0,t.inner||(t.container.append(o.Xt.node({str:'<div class="xt-ripple-inner"></div>'})),t.inner=t.container.querySelector(":scope > .xt-ripple-inner"));const n=o.Xt.dataStorage.put(t.container,`mousedown touchstart/${t.ns}`,t._eventStart.bind(t));t.container.addEventListener("mousedown",n),t.container.addEventListener("touchstart",n,{passive:!0}),t.container.dispatchEvent(new CustomEvent(`setup.${t._componentNs}`)),o.Xt.frameDouble({el:t.container,ns:`${t.ns}Init`,func:()=>{t.container.setAttribute(`data-${t.componentName}-init`,""),t.container.dispatchEvent(new CustomEvent(`init.${t._componentNs}`)),t.initial=!1,e.debug&&console.debug(`${t.componentName} init`,t)}}),t.options.disabled&&t.disable()}_eventStart(t){const e=this,n=e.options;if(!e.disabled&&(!n.onlyInside||t.target.closest(n.onlyInside))){e.inner.append(o.Xt.node({str:'<div class="xt-ripple"></div>'})),"mousedown"===t.type&&t.preventDefault();const i=e.container.offsetHeight,s=e.container.offsetWidth,a=(i>s?i:s)*n.sizeInitial+1,c=Math.sqrt(Math.pow(i,2)+Math.pow(s,2)),r=c/a*2;let d,p;void 0!==t.clientX?(d=t.clientY,p=t.clientX):t.touches&&t.touches.length&&(d=t.touches[0].clientY,p=t.touches[0].clientX);const u=t.target.getBoundingClientRect();if(d-=u.top,p-=u.left,e.container!==t.target){const t=e.container.getBoundingClientRect();d+=u.top-t.top,p+=u.left-t.left}const l=d-a/2,m=p-a/2;e.size=a,e.top=l,e.left=m,e.sizeFinal=c,e.scaleFinal=r,e.container.dispatchEvent(new CustomEvent(`on.${e._componentNs}`,{detail:t}));const v=o.Xt.dataStorage.put(window,`mouseup touchend/${e.ns}`,e._eventEnd.bind(e));addEventListener("mouseup",v),addEventListener("touchend",v,{passive:!0})}}_eventEnd(t){const e=this;if(e.disabled)return;const n=o.Xt.dataStorage.get(window,`mouseup touchend/${e.ns}`);removeEventListener("mouseup",n),removeEventListener("touchend",n),e.container.dispatchEvent(new CustomEvent(`off.${e._componentNs}`,{detail:t}))}enable(){const t=this;t.disabled&&(t.disabled=!1,t.container.dispatchEvent(new CustomEvent(`status.${t._componentNs}`)))}disable(){let{skipEvent:t=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=this;e.disabled||(e.disabled=!0,t||e.container.dispatchEvent(new CustomEvent(`status.${e._componentNs}`)))}reinit(){this._initLogic()}destroy(){const t=this;t.inner.remove(),t.inner=null;const e=o.Xt.dataStorage.get(t.container,`mousedown touchstart/${t.ns}`);t.container.removeEventListener("mousedown",e),t.container.removeEventListener("touchstart",e,{passive:!0});const n=o.Xt.dataStorage.get(window,`mouseup touchend/${t.ns}`);removeEventListener("mouseup",n),removeEventListener("touchend",n),t.container.removeAttribute(`data-${t.componentName}-init`),o.Xt._remove({name:t.componentName,el:t.container}),t.container.dispatchEvent(new CustomEvent(`destroy.${t._componentNs}`))}}}}]);
//# sourceMappingURL=792.min.js.map