{"version":3,"file":"primeng-ripple.umd.js","sources":["../../src/app/components/ripple/ripple.ts","../../src/app/components/ripple/primeng-ripple.ts"],"sourcesContent":["import { NgModule, Directive, AfterViewInit, ElementRef, NgZone, OnDestroy, Optional } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { DomHandler } from 'primeng/dom';\nimport { PrimeNGConfig } from 'primeng/api';\n\n@Directive({\n selector: '[pRipple]',\n host: {\n '[class.p-ripple]': 'true'\n }\n})\nexport class Ripple implements AfterViewInit, OnDestroy {\n\n constructor(public el: ElementRef, public zone: NgZone, @Optional() public config: PrimeNGConfig) { }\n\n animationListener: any;\n\n mouseDownListener: any;\n\n ngAfterViewInit() {\n if (this.config && this.config.ripple) {\n this.zone.runOutsideAngular(() => {\n this.create();\n \n this.mouseDownListener = this.onMouseDown.bind(this);\n this.el.nativeElement.addEventListener('mousedown', this.mouseDownListener);\n });\n }\n }\n\n onMouseDown(event: MouseEvent) {\n let ink = this.getInk();\n if (!ink || getComputedStyle(ink, null).display === 'none') {\n return;\n }\n \n DomHandler.removeClass(ink, 'p-ink-active');\n if (!DomHandler.getHeight(ink) && !DomHandler.getWidth(ink)) {\n let d = Math.max(DomHandler.getOuterWidth(this.el.nativeElement), DomHandler.getOuterHeight(this.el.nativeElement));\n ink.style.height = d + 'px';\n ink.style.width = d + 'px';\n }\n \n let offset = DomHandler.getOffset(this.el.nativeElement);\n let x = event.pageX - offset.left + document.body.scrollTop - DomHandler.getWidth(ink) / 2;\n let y = event.pageY - offset.top + document.body.scrollLeft - DomHandler.getHeight(ink) / 2;\n \n ink.style.top = y + 'px';\n ink.style.left = x + 'px';\n DomHandler.addClass(ink, 'p-ink-active');\n }\n \n getInk() {\n for (let i = 0; i < this.el.nativeElement.children.length; i++) {\n if (this.el.nativeElement.children[i].className.indexOf('p-ink') !== -1) {\n return this.el.nativeElement.children[i];\n }\n }\n return null;\n }\n\n resetInk() {\n let ink = this.getInk();\n if (ink) {\n DomHandler.removeClass(ink, 'p-ink-active');\n }\n }\n\n onAnimationEnd(event) {\n DomHandler.removeClass(event.currentTarget, 'p-ink-active');\n }\n\n create() {\n let ink = document.createElement('span');\n ink.className = 'p-ink';\n this.el.nativeElement.appendChild(ink);\n \n this.animationListener = this.onAnimationEnd.bind(this);\n ink.addEventListener('animationend', this.animationListener);\n }\n\n remove() {\n let ink = this.getInk();\n if (ink) {\n this.el.nativeElement.removeEventListener('mousedown', this.mouseDownListener);\n ink.removeEventListener('animationend', this.animationListener);\n DomHandler.removeElement(ink);\n }\n }\n\n ngOnDestroy() {\n if (this.config && this.config.ripple) {\n this.remove();\n }\n }\n}\n\n@NgModule({\n imports: [CommonModule],\n exports: [Ripple],\n declarations: [Ripple]\n})\nexport class RippleModule { }\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["DomHandler","Directive","ElementRef","NgZone","PrimeNGConfig","Optional","NgModule","CommonModule"],"mappings":";;;;;;;QAaI,gBAAmB,EAAc,EAAS,IAAY,EAAqB,MAAqB;YAA7E,OAAE,GAAF,EAAE,CAAY;YAAS,SAAI,GAAJ,IAAI,CAAQ;YAAqB,WAAM,GAAN,MAAM,CAAe;SAAK;QAMrG,gCAAe,GAAf;YAAA,iBASC;YARG,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;gBACnC,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC;oBACxB,KAAI,CAAC,MAAM,EAAE,CAAC;oBAEd,KAAI,CAAC,iBAAiB,GAAG,KAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAI,CAAC,CAAC;oBACrD,KAAI,CAAC,EAAE,CAAC,aAAa,CAAC,gBAAgB,CAAC,WAAW,EAAE,KAAI,CAAC,iBAAiB,CAAC,CAAC;iBAC/E,CAAC,CAAC;aACN;SACJ;QAED,4BAAW,GAAX,UAAY,KAAiB;YACzB,IAAI,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;YACxB,IA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