2 lines
3.7 KiB
JavaScript
2 lines
3.7 KiB
JavaScript
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),e=require("primereact/utils"),n=require("primereact/api");function o(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var r=o(t),i=o(n);function u(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function s(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function c(t,e){return c=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},c(t,e)}function l(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&c(t,e)}function f(t){return f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},f(t)}function p(t,e){if(e&&("object"===f(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return s(t)}function h(t){return h=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},h(t)}function y(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}exports.Ripple=function(n){l(b,t.Component);var o,c,f,d,m,v=(o=b,c=y(),function(){var t,e=h(o);if(c){var n=h(this).constructor;t=Reflect.construct(e,arguments,n)}else t=e.apply(this,arguments);return p(this,t)});function b(t){var e;return u(this,b),(e=v.call(this,t)).onMouseDown=e.onMouseDown.bind(s(e)),e}return f=b,(d=[{key:"getTarget",value:function(){return this.ink&&this.ink.parentElement}},{key:"bindEvents",value:function(){this.target&&this.target.addEventListener("mousedown",this.onMouseDown)}},{key:"unbindEvents",value:function(){this.target&&this.target.removeEventListener("mousedown",this.onMouseDown)}},{key:"onMouseDown",value:function(t){if(this.ink&&"none"!==getComputedStyle(this.ink,null).display){if(e.DomHandler.removeClass(this.ink,"p-ink-active"),!e.DomHandler.getHeight(this.ink)&&!e.DomHandler.getWidth(this.ink)){var n=Math.max(e.DomHandler.getOuterWidth(this.target),e.DomHandler.getOuterHeight(this.target));this.ink.style.height=n+"px",this.ink.style.width=n+"px"}var o=e.DomHandler.getOffset(this.target),r=t.pageX-o.left+document.body.scrollTop-e.DomHandler.getWidth(this.ink)/2,i=t.pageY-o.top+document.body.scrollLeft-e.DomHandler.getHeight(this.ink)/2;this.ink.style.top=i+"px",this.ink.style.left=r+"px",e.DomHandler.addClass(this.ink,"p-ink-active")}}},{key:"onAnimationEnd",value:function(t){e.DomHandler.removeClass(t.currentTarget,"p-ink-active")}},{key:"componentDidMount",value:function(){this.ink&&(this.target=this.getTarget(),this.bindEvents())}},{key:"componentDidUpdate",value:function(){this.ink&&!this.target&&(this.target=this.getTarget(),this.bindEvents())}},{key:"componentWillUnmount",value:function(){this.ink&&(this.target=null,this.unbindEvents())}},{key:"render",value:function(){var t=this;return i.default.ripple?r.default.createElement("span",{ref:function(e){return t.ink=e},className:"p-ink",onAnimationEnd:this.onAnimationEnd}):null}}])&&a(f.prototype,d),m&&a(f,m),Object.defineProperty(f,"prototype",{writable:!1}),b}();
|