source: trip-planner-front/node_modules/primeng/fesm2020/primeng-scrolltop.mjs@ 571e0df

Last change on this file since 571e0df was 59329aa, checked in by Ema <ema_spirova@…>, 3 years ago

adding photos

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