1 | import { NgModule, Component, ChangeDetectionStrategy, ViewEncapsulation, Input } from '@angular/core';
|
---|
2 | import { CommonModule } from '@angular/common';
|
---|
3 | import { animate, state, style, transition, trigger } from '@angular/animations';
|
---|
4 | import { DomHandler } from 'primeng/dom';
|
---|
5 | import { ZIndexUtils } from 'primeng/utils';
|
---|
6 | import * as i0 from "@angular/core";
|
---|
7 | import * as i1 from "primeng/api";
|
---|
8 | import * as i2 from "@angular/common";
|
---|
9 | export class ScrollTop {
|
---|
10 | constructor(el, cd, config) {
|
---|
11 | this.el = el;
|
---|
12 | this.cd = cd;
|
---|
13 | this.config = config;
|
---|
14 | this.target = "window";
|
---|
15 | this.threshold = 400;
|
---|
16 | this.icon = "pi pi-chevron-up";
|
---|
17 | this.behavior = "smooth";
|
---|
18 | this.showTransitionOptions = '.15s';
|
---|
19 | this.hideTransitionOptions = '.15s';
|
---|
20 | this.visible = false;
|
---|
21 | }
|
---|
22 | ngOnInit() {
|
---|
23 | if (this.target === 'window')
|
---|
24 | this.bindDocumentScrollListener();
|
---|
25 | else if (this.target === 'parent')
|
---|
26 | this.bindParentScrollListener();
|
---|
27 | }
|
---|
28 | onClick() {
|
---|
29 | let scrollElement = this.target === 'window' ? window : this.el.nativeElement.parentElement;
|
---|
30 | scrollElement.scroll({
|
---|
31 | top: 0,
|
---|
32 | behavior: this.behavior
|
---|
33 | });
|
---|
34 | }
|
---|
35 | onEnter(event) {
|
---|
36 | switch (event.toState) {
|
---|
37 | case 'open':
|
---|
38 | this.overlay = event.element;
|
---|
39 | ZIndexUtils.set('overlay', this.overlay, this.config.zIndex.overlay);
|
---|
40 | break;
|
---|
41 | case 'void':
|
---|
42 | this.overlay = null;
|
---|
43 | break;
|
---|
44 | }
|
---|
45 | }
|
---|
46 | onLeave(event) {
|
---|
47 | switch (event.toState) {
|
---|
48 | case 'void':
|
---|
49 | ZIndexUtils.clear(event.element);
|
---|
50 | break;
|
---|
51 | }
|
---|
52 | }
|
---|
53 | checkVisibility(scrollY) {
|
---|
54 | if (scrollY > this.threshold)
|
---|
55 | this.visible = true;
|
---|
56 | else
|
---|
57 | this.visible = false;
|
---|
58 | this.cd.markForCheck();
|
---|
59 | }
|
---|
60 | bindParentScrollListener() {
|
---|
61 | this.scrollListener = () => {
|
---|
62 | this.checkVisibility(this.el.nativeElement.parentElement.scrollTop);
|
---|
63 | };
|
---|
64 | this.el.nativeElement.parentElement.addEventListener('scroll', this.scrollListener);
|
---|
65 | }
|
---|
66 | bindDocumentScrollListener() {
|
---|
67 | this.scrollListener = () => {
|
---|
68 | this.checkVisibility(DomHandler.getWindowScrollTop());
|
---|
69 | };
|
---|
70 | window.addEventListener('scroll', this.scrollListener);
|
---|
71 | }
|
---|
72 | unbindParentScrollListener() {
|
---|
73 | if (this.scrollListener) {
|
---|
74 | this.el.nativeElement.parentElement.removeEventListener('scroll', this.scrollListener);
|
---|
75 | this.scrollListener = null;
|
---|
76 | }
|
---|
77 | }
|
---|
78 | unbindDocumentScrollListener() {
|
---|
79 | if (this.scrollListener) {
|
---|
80 | window.removeEventListener('scroll', this.scrollListener);
|
---|
81 | this.scrollListener = null;
|
---|
82 | }
|
---|
83 | }
|
---|
84 | containerClass() {
|
---|
85 | return {
|
---|
86 | 'p-scrolltop p-link p-component': true,
|
---|
87 | 'p-scrolltop-sticky': this.target !== 'window'
|
---|
88 | };
|
---|
89 | }
|
---|
90 | ngOnDestroy() {
|
---|
91 | if (this.target === 'window')
|
---|
92 | this.unbindDocumentScrollListener();
|
---|
93 | else if (this.target === 'parent')
|
---|
94 | this.unbindParentScrollListener();
|
---|
95 | if (this.overlay) {
|
---|
96 | ZIndexUtils.clear(this.overlay);
|
---|
97 | this.overlay = null;
|
---|
98 | }
|
---|
99 | }
|
---|
100 | }
|
---|
101 | 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 });
|
---|
102 | 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: `
|
---|
103 | <button *ngIf="visible" [@animation]="{value: 'open', params: {showTransitionParams: showTransitionOptions, hideTransitionParams: hideTransitionOptions}}" (@animation.start)="onEnter($event)" (@animation.done)="onLeave($event)"
|
---|
104 | [ngClass]="containerClass()" (click)="onClick()" [class]="styleClass" [ngStyle]="style" type="button">
|
---|
105 | <span [class]="icon" [ngClass]="'p-scrolltop-icon'"></span>
|
---|
106 | </button>
|
---|
107 | `, 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: [
|
---|
108 | trigger('animation', [
|
---|
109 | state('void', style({
|
---|
110 | opacity: 0
|
---|
111 | })),
|
---|
112 | state('open', style({
|
---|
113 | opacity: 1
|
---|
114 | })),
|
---|
115 | transition('void => open', animate('{{showTransitionParams}}')),
|
---|
116 | transition('open => void', animate('{{hideTransitionParams}}')),
|
---|
117 | ])
|
---|
118 | ], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
---|
119 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ScrollTop, decorators: [{
|
---|
120 | type: Component,
|
---|
121 | args: [{ selector: 'p-scrollTop', template: `
|
---|
122 | <button *ngIf="visible" [@animation]="{value: 'open', params: {showTransitionParams: showTransitionOptions, hideTransitionParams: hideTransitionOptions}}" (@animation.start)="onEnter($event)" (@animation.done)="onLeave($event)"
|
---|
123 | [ngClass]="containerClass()" (click)="onClick()" [class]="styleClass" [ngStyle]="style" type="button">
|
---|
124 | <span [class]="icon" [ngClass]="'p-scrolltop-icon'"></span>
|
---|
125 | </button>
|
---|
126 | `, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, animations: [
|
---|
127 | trigger('animation', [
|
---|
128 | state('void', style({
|
---|
129 | opacity: 0
|
---|
130 | })),
|
---|
131 | state('open', style({
|
---|
132 | opacity: 1
|
---|
133 | })),
|
---|
134 | transition('void => open', animate('{{showTransitionParams}}')),
|
---|
135 | transition('open => void', animate('{{hideTransitionParams}}')),
|
---|
136 | ])
|
---|
137 | ], host: {
|
---|
138 | 'class': 'p-element'
|
---|
139 | }, 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"] }]
|
---|
140 | }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i1.PrimeNGConfig }]; }, propDecorators: { styleClass: [{
|
---|
141 | type: Input
|
---|
142 | }], style: [{
|
---|
143 | type: Input
|
---|
144 | }], target: [{
|
---|
145 | type: Input
|
---|
146 | }], threshold: [{
|
---|
147 | type: Input
|
---|
148 | }], icon: [{
|
---|
149 | type: Input
|
---|
150 | }], behavior: [{
|
---|
151 | type: Input
|
---|
152 | }], showTransitionOptions: [{
|
---|
153 | type: Input
|
---|
154 | }], hideTransitionOptions: [{
|
---|
155 | type: Input
|
---|
156 | }] } });
|
---|
157 | export class ScrollTopModule {
|
---|
158 | }
|
---|
159 | ScrollTopModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ScrollTopModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
---|
160 | ScrollTopModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ScrollTopModule, declarations: [ScrollTop], imports: [CommonModule], exports: [ScrollTop] });
|
---|
161 | ScrollTopModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ScrollTopModule, imports: [[CommonModule]] });
|
---|
162 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ScrollTopModule, decorators: [{
|
---|
163 | type: NgModule,
|
---|
164 | args: [{
|
---|
165 | imports: [CommonModule],
|
---|
166 | exports: [ScrollTop],
|
---|
167 | declarations: [ScrollTop]
|
---|
168 | }]
|
---|
169 | }] });
|
---|
170 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2Nyb2xsdG9wLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2FwcC9jb21wb25lbnRzL3Njcm9sbHRvcC9zY3JvbGx0b3AudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFFBQVEsRUFBRSxTQUFTLEVBQUUsdUJBQXVCLEVBQUUsaUJBQWlCLEVBQUUsS0FBSyxFQUFtRCxNQUFNLGVBQWUsQ0FBQztBQUN4SixPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0saUJBQWlCLENBQUM7QUFDL0MsT0FBTyxFQUFFLE9BQU8sRUFBRSxLQUFLLEVBQUUsS0FBSyxFQUFFLFVBQVUsRUFBRSxPQUFPLEVBQWtCLE1BQU0scUJBQXFCLENBQUM7QUFDakcsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLGFBQWEsQ0FBQztBQUN6QyxPQUFPLEVBQUUsV0FBVyx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1hdGlvbkV2ZW50KSB7XG5cbiAgICAgICAgc3dpdGNoKGV2ZW50LnRvU3RhdGUpIHtcbiAgICAgICAgICAgIGNhc2UgJ29wZW4nOlxuICAgICAgICAgICAgICAgIHRoaXMub3ZlcmxheSA9IGV2ZW50LmVsZW1lbnQ7XG4gICAgICAgICAgICAgICAgWkluZGV4VXRpbHMuc2V0KCdvdmVybGF5JywgdGhpcy5vdmVybGF5LCB0aGlzLmNvbmZpZy56SW5kZXgub3ZlcmxheSk7XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIGNhc2UgJ3ZvaWQnOlxuICAgICAgICAgICAgICAgIHRoaXMub3ZlcmxheSA9IG51bGw7XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgfVxuICAgIH1cblxuICAgIG9uTGVhdmUoZXZlbnQ6IEFuaW1hdGlvbkV2ZW50KSB7XG4gICAgICAgIHN3aXRjaChldmVudC50b1N0YXRlKSB7XG4gICAgICAgICAgICBjYXNlICd2b2lkJzpcbiAgICAgICAgICAgICAgICBaSW5kZXhVdGlscy5jbGVhcihldmVudC5lbGVtZW50KTtcbiAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgY2hlY2tWaXNpYmlsaXR5KHNjcm9sbFkpIHtcbiAgICAgICAgaWYgKHNjcm9sbFkgPiB0aGlzLnRocmVzaG9sZClcbiAgICAgICAgICAgIHRoaXMudmlzaWJsZSA9IHRydWU7XG4gICAgICAgIGVsc2VcbiAgICAgICAgICAgIHRoaXMudmlzaWJsZSA9IGZhbHNlO1xuXG4gICAgICAgIHRoaXMuY2QubWFya0ZvckNoZWNrKCk7XG4gICAgfVxuXG4gICAgYmluZFBhcmVudFNjcm9sbExpc3RlbmVyKCkge1xuICAgICAgICB0aGlzLnNjcm9sbExpc3RlbmVyID0gKCkgPT4ge1xuXG4gICAgICAgICAgICB0aGlzLmNoZWNrVmlzaWJpbGl0eSh0aGlzLmVsLm5hdGl2ZUVsZW1lb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