import * as i0 from '@angular/core'; import { Directive, Optional, NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { DomHandler } from 'primeng/dom'; import * as i1 from 'primeng/api'; class Ripple { constructor(el, zone, config) { this.el = el; this.zone = zone; this.config = config; } ngAfterViewInit() { if (this.config && this.config.ripple) { this.zone.runOutsideAngular(() => { this.create(); this.mouseDownListener = this.onMouseDown.bind(this); this.el.nativeElement.addEventListener('mousedown', this.mouseDownListener); }); } } onMouseDown(event) { let ink = this.getInk(); if (!ink || getComputedStyle(ink, null).display === 'none') { return; } DomHandler.removeClass(ink, 'p-ink-active'); if (!DomHandler.getHeight(ink) && !DomHandler.getWidth(ink)) { let d = Math.max(DomHandler.getOuterWidth(this.el.nativeElement), DomHandler.getOuterHeight(this.el.nativeElement)); ink.style.height = d + 'px'; ink.style.width = d + 'px'; } let offset = DomHandler.getOffset(this.el.nativeElement); let x = event.pageX - offset.left + document.body.scrollTop - DomHandler.getWidth(ink) / 2; let y = event.pageY - offset.top + document.body.scrollLeft - DomHandler.getHeight(ink) / 2; ink.style.top = y + 'px'; ink.style.left = x + 'px'; DomHandler.addClass(ink, 'p-ink-active'); } getInk() { for (let i = 0; i < this.el.nativeElement.children.length; i++) { if (this.el.nativeElement.children[i].className.indexOf('p-ink') !== -1) { return this.el.nativeElement.children[i]; } } return null; } resetInk() { let ink = this.getInk(); if (ink) { DomHandler.removeClass(ink, 'p-ink-active'); } } onAnimationEnd(event) { DomHandler.removeClass(event.currentTarget, 'p-ink-active'); } create() { let ink = document.createElement('span'); ink.className = 'p-ink'; this.el.nativeElement.appendChild(ink); this.animationListener = this.onAnimationEnd.bind(this); ink.addEventListener('animationend', this.animationListener); } remove() { let ink = this.getInk(); if (ink) { this.el.nativeElement.removeEventListener('mousedown', this.mouseDownListener); ink.removeEventListener('animationend', this.animationListener); DomHandler.removeElement(ink); } } ngOnDestroy() { if (this.config && this.config.ripple) { this.remove(); } } } Ripple.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: Ripple, deps: [{ token: i0.ElementRef }, { token: i0.NgZone }, { token: i1.PrimeNGConfig, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); Ripple.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0", type: Ripple, selector: "[pRipple]", host: { classAttribute: "p-ripple p-element" }, ngImport: i0 }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: Ripple, decorators: [{ type: Directive, args: [{ selector: '[pRipple]', host: { 'class': 'p-ripple p-element' } }] }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.NgZone }, { type: i1.PrimeNGConfig, decorators: [{ type: Optional }] }]; } }); class RippleModule { } RippleModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: RippleModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); RippleModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: RippleModule, declarations: [Ripple], imports: [CommonModule], exports: [Ripple] }); RippleModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: RippleModule, imports: [[CommonModule]] }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: RippleModule, decorators: [{ type: NgModule, args: [{ imports: [CommonModule], exports: [Ripple], declarations: [Ripple] }] }] }); /** * Generated bundle index. Do not edit. */ export { Ripple, RippleModule };