Icard/angular-clarity-master(work.../node_modules/primeng/fesm2022/primeng-animate.mjs

109 lines
4.3 KiB
JavaScript

import { CommonModule } from '@angular/common';
import * as i0 from '@angular/core';
import { Directive, Input, NgModule } from '@angular/core';
import { DomHandler } from 'primeng/dom';
/**
* Animate manages PrimeFlex CSS classes declaratively to during enter/leave animations on scroll or on page load.
* @group Components
*/
class Animate {
host;
el;
renderer;
/**
* Selector to define the CSS class for enter animation.
* @group Props
*/
enterClass;
/**
* Selector to define the CSS class for leave animation.
* @group Props
*/
leaveClass;
observer;
timeout;
constructor(host, el, renderer) {
this.host = host;
this.el = el;
this.renderer = renderer;
}
ngOnInit() {
console.log('pAnimate directive is deprecated in 16.7.0 and will be removed in the future. Use pAnimateOnScroll directive instead');
}
ngAfterViewInit() {
this.bindIntersectionObserver();
}
bindIntersectionObserver() {
const options = {
root: null,
rootMargin: '0px',
threshold: 1.0
};
this.observer = new IntersectionObserver((el) => this.isVisible(el), options);
this.observer.observe(this.host.nativeElement);
}
isVisible(element) {
const [intersectionObserverEntry] = element;
intersectionObserverEntry.isIntersecting ? this.enter() : this.leave();
}
enter() {
this.host.nativeElement.style.visibility = 'visible';
DomHandler.addClass(this.host.nativeElement, this.enterClass);
}
leave() {
DomHandler.removeClass(this.host.nativeElement, this.enterClass);
if (this.leaveClass) {
DomHandler.addClass(this.host.nativeElement, this.leaveClass);
}
const animationDuration = this.host.nativeElement.style.animationDuration || 500;
this.timeout = setTimeout(() => {
this.host.nativeElement.style.visibility = 'hidden';
}, animationDuration);
}
unbindIntersectionObserver() {
if (this.observer) {
this.observer.unobserve(this.host.nativeElement);
}
}
ngOnDestroy() {
this.unbindIntersectionObserver();
clearTimeout(this.timeout);
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: Animate, deps: [{ token: i0.ElementRef }, { token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.3.7", type: Animate, selector: "[pAnimate]", inputs: { enterClass: "enterClass", leaveClass: "leaveClass" }, host: { properties: { "class.p-animate": "true" } }, ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: Animate, decorators: [{
type: Directive,
args: [{
selector: '[pAnimate]',
host: {
'[class.p-animate]': 'true'
}
}]
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.ElementRef }, { type: i0.Renderer2 }], propDecorators: { enterClass: [{
type: Input
}], leaveClass: [{
type: Input
}] } });
class AnimateModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: AnimateModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.7", ngImport: i0, type: AnimateModule, declarations: [Animate], imports: [CommonModule], exports: [Animate] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: AnimateModule, imports: [CommonModule] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: AnimateModule, decorators: [{
type: NgModule,
args: [{
imports: [CommonModule],
exports: [Animate],
declarations: [Animate]
}]
}] });
/**
* Generated bundle index. Do not edit.
*/
export { Animate, AnimateModule };
//# sourceMappingURL=primeng-animate.mjs.map