{"version":3,"sources":["../../src/app/components/ripple/ripple.ts"],"names":["Ripple","el","zone","config","this","prototype","ngAfterViewInit","_this","ripple","runOutsideAngular","create","mouseDownListener","onMouseDown","bind","nativeElement","addEventListener","event","ink","getInk","getComputedStyle","display","DomHandler","removeClass","getHeight","getWidth","d","Math","max","getOuterWidth","getOuterHeight","style","height","width","offset","getOffset","x","pageX","left","document","body","scrollTop","y","pageY","top","scrollLeft","addClass","i","children","length","className","indexOf","resetInk","onAnimationEnd","currentTarget","createElement","appendChild","animationListener","remove","removeEventListener","removeElement","ngOnDestroy","Directive","args","selector","host","[class.p-ripple]","ElementRef","NgZone","PrimeNGConfig","decorators","type","Optional","NgModule","imports","CommonModule","exports","declarations"],"mappings":"4gBAaI,SAAAA,EAAmBC,EAAuBC,EAAiCC,GAAxDC,KAAAH,GAAAA,EAAuBG,KAAAF,KAAAA,EAAiCE,KAAAD,OAAAA,SAM3EH,EAAAK,UAAAC,gBAAA,WAAA,IAAAC,EAAAH,KACQA,KAAKD,QAAUC,KAAKD,OAAOK,QAC3BJ,KAAKF,KAAKO,mBAAkB,WACxBF,EAAKG,SAELH,EAAKI,kBAAoBJ,EAAKK,YAAYC,KAAKN,GAC/CA,EAAKN,GAAGa,cAAcC,iBAAiB,YAAaR,EAAKI,uBAKrEX,EAAAK,UAAAO,YAAA,SAAYI,GACR,IAAIC,EAAMb,KAAKc,SACf,GAAKD,GAA+C,SAAxCE,iBAAiBF,EAAK,MAAMG,QAAxC,CAKA,GADAC,EAAAA,WAAWC,YAAYL,EAAK,iBACvBI,EAAAA,WAAWE,UAAUN,KAASI,EAAAA,WAAWG,SAASP,GAAM,CACzD,IAAIQ,EAAIC,KAAKC,IAAIN,EAAAA,WAAWO,cAAcxB,KAAKH,GAAGa,eAAgBO,EAAAA,WAAWQ,eAAezB,KAAKH,GAAGa,gBACpGG,EAAIa,MAAMC,OAASN,EAAI,KACvBR,EAAIa,MAAME,MAAQP,EAAI,KAG1B,IAAIQ,EAASZ,EAAA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,KAAKqD,mCAvFhBI,EAAAA,UAASC,KAAA,CAAC,CACPC,SAAU,YACVC,KAAM,CACFC,mBAAoB,qDARiBC,EAAAA,kBAAYC,EAAAA,cAGhDC,EAAAA,cAAaC,WAAA,CAAA,CAAAC,KAUuCC,EAAAA,oBAyF7D,iCALCC,EAAAA,SAAQV,KAAA,CAAC,CACNW,QAAS,CAACC,EAAAA,cACVC,QAAS,CAAC3E,GACV4E,aAAc,CAAC5E","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"]}