UNPKG

primevue

Version:

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![npm version](https://badge.fury.io/js/primevue.svg)](https://badge.fury.io/js/primevue) [![Discord Chat](https://img.shields.io/discord/55794023

2 lines (1 loc) 3.65 kB
this.primevue=this.primevue||{},this.primevue.ripple=function(e,t,n){"use strict";function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=i(t),o=n.useStyle("\n.p-ripple {\n overflow: hidden;\n position: relative;\n}\n\n.p-ink {\n display: block;\n position: absolute;\n background: rgba(255, 255, 255, 0.5);\n border-radius: 100%;\n transform: scale(0);\n pointer-events: none;\n}\n\n.p-ink-active {\n animation: ripple 0.4s linear;\n}\n\n.p-ripple-disabled .p-ink {\n display: none !important;\n}\n\n@keyframes ripple {\n 100% {\n opacity: 0;\n transform: scale(2.5);\n }\n}\n",{name:"ripple",manual:!0});function a(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function s(e,t){if(e){if("string"==typeof e)return u(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(e,t):void 0}}function l(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function d(e){if(Array.isArray(e))return u(e)}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}return r.default.extend({css:{classes:{root:"p-ink"},loadStyle:o.load}}).extend("ripple",{mounted:function(e,t){var n,i=t.instance.$primevue;i&&i.config&&i.config.ripple&&(e.unstyled=i.config.unstyled||(null===(n=t.value)||void 0===n?void 0:n.unstyled)||!1,this.create(e),this.bindEvents(e));e.setAttribute("data-pd-ripple",!0)},unmounted:function(e){this.remove(e)},timeout:void 0,methods:{bindEvents:function(e){e.addEventListener("mousedown",this.onMouseDown.bind(this))},unbindEvents:function(e){e.removeEventListener("mousedown",this.onMouseDown.bind(this))},create:function(t){var n=e.DomHandler.createElement("span",{role:"presentation","aria-hidden":!0,"data-p-ink":!0,"data-p-ink-active":!1,class:!t.unstyled&&this.cx("root"),onAnimationEnd:this.onAnimationEnd,"p-bind":this.ptm("root")});t.appendChild(n),this.$el=n},remove:function(e){var t=this.getInk(e);t&&(this.unbindEvents(e),t.removeEventListener("animationend",this.onAnimationEnd),t.remove())},onMouseDown:function(t){var n=t.currentTarget,i=this.getInk(n);if(i&&"none"!==getComputedStyle(i,null).display){if(!n.unstyled&&e.DomHandler.removeClass(i,"p-ink-active"),i.setAttribute("data-p-ink-active","false"),!e.DomHandler.getHeight(i)&&!e.DomHandler.getWidth(i)){var r=Math.max(e.DomHandler.getOuterWidth(n),e.DomHandler.getOuterHeight(n));i.style.height=r+"px",i.style.width=r+"px"}var o=e.DomHandler.getOffset(n),a=t.pageX-o.left+document.body.scrollTop-e.DomHandler.getWidth(i)/2,s=t.pageY-o.top+document.body.scrollLeft-e.DomHandler.getHeight(i)/2;i.style.top=s+"px",i.style.left=a+"px",!n.unstyled&&e.DomHandler.addClass(i,"p-ink-active"),i.setAttribute("data-p-ink-active","true"),this.timeout=setTimeout((function(){i&&(!n.unstyled&&e.DomHandler.removeClass(i,"p-ink-active"),i.setAttribute("data-p-ink-active","false"))}),401)}},onAnimationEnd:function(t){this.timeout&&clearTimeout(this.timeout),!t.currentTarget.unstyled&&e.DomHandler.removeClass(t.currentTarget,"p-ink-active"),t.currentTarget.setAttribute("data-p-ink-active","false")},getInk:function(t){return t&&t.children?(n=t.children,d(n)||l(n)||s(n)||a()).find((function(t){return"ripple"===e.DomHandler.getAttribute(t,"data-pc-name")})):void 0;var n}}})}(primevue.utils,primevue.basedirective,primevue.usestyle);