import { NgModule, Component, ChangeDetectionStrategy, ViewEncapsulation, Input } from '@angular/core';
import { CommonModule } from '@angular/common';
import { animate, state, style, transition, trigger } from '@angular/animations';
import { DomHandler } from 'primeng/dom';
import { ZIndexUtils } from 'primeng/utils';
import * as i0 from "@angular/core";
import * as i1 from "primeng/api";
import * as i2 from "@angular/common";
export class ScrollTop {
constructor(el, cd, config) {
this.el = el;
this.cd = cd;
this.config = config;
this.target = "window";
this.threshold = 400;
this.icon = "pi pi-chevron-up";
this.behavior = "smooth";
this.showTransitionOptions = '.15s';
this.hideTransitionOptions = '.15s';
this.visible = false;
}
ngOnInit() {
if (this.target === 'window')
this.bindDocumentScrollListener();
else if (this.target === 'parent')
this.bindParentScrollListener();
}
onClick() {
let scrollElement = this.target === 'window' ? window : this.el.nativeElement.parentElement;
scrollElement.scroll({
top: 0,
behavior: this.behavior
});
}
onEnter(event) {
switch (event.toState) {
case 'open':
this.overlay = event.element;
ZIndexUtils.set('overlay', this.overlay, this.config.zIndex.overlay);
break;
case 'void':
this.overlay = null;
break;
}
}
onLeave(event) {
switch (event.toState) {
case 'void':
ZIndexUtils.clear(event.element);
break;
}
}
checkVisibility(scrollY) {
if (scrollY > this.threshold)
this.visible = true;
else
this.visible = false;
this.cd.markForCheck();
}
bindParentScrollListener() {
this.scrollListener = () => {
this.checkVisibility(this.el.nativeElement.parentElement.scrollTop);
};
this.el.nativeElement.parentElement.addEventListener('scroll', this.scrollListener);
}
bindDocumentScrollListener() {
this.scrollListener = () => {
this.checkVisibility(DomHandler.getWindowScrollTop());
};
window.addEventListener('scroll', this.scrollListener);
}
unbindParentScrollListener() {
if (this.scrollListener) {
this.el.nativeElement.parentElement.removeEventListener('scroll', this.scrollListener);
this.scrollListener = null;
}
}
unbindDocumentScrollListener() {
if (this.scrollListener) {
window.removeEventListener('scroll', this.scrollListener);
this.scrollListener = null;
}
}
containerClass() {
return {
'p-scrolltop p-link p-component': true,
'p-scrolltop-sticky': this.target !== 'window'
};
}
ngOnDestroy() {
if (this.target === 'window')
this.unbindDocumentScrollListener();
else if (this.target === 'parent')
this.unbindParentScrollListener();
if (this.overlay) {
ZIndexUtils.clear(this.overlay);
this.overlay = null;
}
}
}
ScrollTop.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ScrollTop, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: i1.PrimeNGConfig }], target: i0.ɵɵFactoryTarget.Component });
ScrollTop.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: ScrollTop, selector: "p-scrollTop", inputs: { styleClass: "styleClass", style: "style", target: "target", threshold: "threshold", icon: "icon", behavior: "behavior", showTransitionOptions: "showTransitionOptions", hideTransitionOptions: "hideTransitionOptions" }, host: { classAttribute: "p-element" }, ngImport: i0, template: `
`, isInline: true, styles: [".p-scrolltop{position:fixed;bottom:20px;right:20px;display:flex;align-items:center;justify-content:center}.p-scrolltop-sticky{position:sticky}.p-scrolltop-sticky.p-link{margin-left:auto}\n"], directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }], animations: [
trigger('animation', [
state('void', style({
opacity: 0
})),
state('open', style({
opacity: 1
})),
transition('void => open', animate('{{showTransitionParams}}')),
transition('open => void', animate('{{hideTransitionParams}}')),
])
], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ScrollTop, decorators: [{
type: Component,
args: [{ selector: 'p-scrollTop', template: `
`, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, animations: [
trigger('animation', [
state('void', style({
opacity: 0
})),
state('open', style({
opacity: 1
})),
transition('void => open', animate('{{showTransitionParams}}')),
transition('open => void', animate('{{hideTransitionParams}}')),
])
], host: {
'class': 'p-element'
}, styles: [".p-scrolltop{position:fixed;bottom:20px;right:20px;display:flex;align-items:center;justify-content:center}.p-scrolltop-sticky{position:sticky}.p-scrolltop-sticky.p-link{margin-left:auto}\n"] }]
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i1.PrimeNGConfig }]; }, propDecorators: { styleClass: [{
type: Input
}], style: [{
type: Input
}], target: [{
type: Input
}], threshold: [{
type: Input
}], icon: [{
type: Input
}], behavior: [{
type: Input
}], showTransitionOptions: [{
type: Input
}], hideTransitionOptions: [{
type: Input
}] } });
export class ScrollTopModule {
}
ScrollTopModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ScrollTopModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
ScrollTopModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ScrollTopModule, declarations: [ScrollTop], imports: [CommonModule], exports: [ScrollTop] });
ScrollTopModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ScrollTopModule, imports: [[CommonModule]] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ScrollTopModule, decorators: [{
type: NgModule,
args: [{
imports: [CommonModule],
exports: [ScrollTop],
declarations: [ScrollTop]
}]
}] });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2Nyb2xsdG9wLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2FwcC9jb21wb25lbnRzL3Njcm9sbHRvcC9zY3JvbGx0b3AudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFFBQVEsRUFBRSxTQ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