1 | import { InjectionToken, PLATFORM_ID, NgZone, Inject, Optional, ElementRef, Directive, Input, Output, EventEmitter, KeyValueDiffers, Component, HostBinding, ViewChild, ViewEncapsulation, ChangeDetectorRef, NgModule } from '@angular/core';
|
2 | import PerfectScrollbar from 'perfect-scrollbar';
|
3 | import ResizeObserver from 'resize-observer-polyfill';
|
4 | import { Subject, fromEvent, merge } from 'rxjs';
|
5 | import { takeUntil, debounceTime, map, distinctUntilChanged } from 'rxjs/operators';
|
6 | import { isPlatformBrowser, CommonModule } from '@angular/common';
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | var PERFECT_SCROLLBAR_CONFIG = new InjectionToken('PERFECT_SCROLLBAR_CONFIG');
|
13 | var Geometry = (function () {
|
14 | function Geometry(x, y, w, h) {
|
15 | this.x = x;
|
16 | this.y = y;
|
17 | this.w = w;
|
18 | this.h = h;
|
19 | }
|
20 | return Geometry;
|
21 | }());
|
22 | var Position = (function () {
|
23 | function Position(x, y) {
|
24 | this.x = x;
|
25 | this.y = y;
|
26 | }
|
27 | return Position;
|
28 | }());
|
29 | var PerfectScrollbarEvents = [
|
30 | 'psScrollY',
|
31 | 'psScrollX',
|
32 | 'psScrollUp',
|
33 | 'psScrollDown',
|
34 | 'psScrollLeft',
|
35 | 'psScrollRight',
|
36 | 'psYReachEnd',
|
37 | 'psYReachStart',
|
38 | 'psXReachEnd',
|
39 | 'psXReachStart'
|
40 | ];
|
41 | var PerfectScrollbarConfig = (function () {
|
42 | function PerfectScrollbarConfig(config) {
|
43 | if (config === void 0) { config = {}; }
|
44 | this.assign(config);
|
45 | }
|
46 | |
47 |
|
48 |
|
49 |
|
50 | PerfectScrollbarConfig.prototype.assign = |
51 |
|
52 |
|
53 |
|
54 | function (config) {
|
55 | if (config === void 0) { config = {}; }
|
56 | for (var key in config) {
|
57 | this[ (key)] = config[ (key)];
|
58 | }
|
59 | };
|
60 | return PerfectScrollbarConfig;
|
61 | }());
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 | var PerfectScrollbarDirective = (function () {
|
68 | function PerfectScrollbarDirective(zone, differs, elementRef, platformId, defaults) {
|
69 | this.zone = zone;
|
70 | this.differs = differs;
|
71 | this.elementRef = elementRef;
|
72 | this.platformId = platformId;
|
73 | this.defaults = defaults;
|
74 | this.instance = null;
|
75 | this.ro = null;
|
76 | this.timeout = null;
|
77 | this.configDiff = null;
|
78 | this.ngDestroy = new Subject();
|
79 | this.disabled = false;
|
80 | this.psScrollY = new EventEmitter();
|
81 | this.psScrollX = new EventEmitter();
|
82 | this.psScrollUp = new EventEmitter();
|
83 | this.psScrollDown = new EventEmitter();
|
84 | this.psScrollLeft = new EventEmitter();
|
85 | this.psScrollRight = new EventEmitter();
|
86 | this.psYReachEnd = new EventEmitter();
|
87 | this.psYReachStart = new EventEmitter();
|
88 | this.psXReachEnd = new EventEmitter();
|
89 | this.psXReachStart = new EventEmitter();
|
90 | }
|
91 | |
92 |
|
93 |
|
94 | PerfectScrollbarDirective.prototype.ngOnInit = |
95 |
|
96 |
|
97 | function () {
|
98 | var _this = this;
|
99 | if (!this.disabled && isPlatformBrowser(this.platformId)) {
|
100 | var config_1 = new PerfectScrollbarConfig(this.defaults);
|
101 | config_1.assign(this.config);
|
102 | this.zone.runOutsideAngular(function () {
|
103 | _this.instance = new PerfectScrollbar(_this.elementRef.nativeElement, config_1);
|
104 | });
|
105 | if (!this.configDiff) {
|
106 | this.configDiff = this.differs.find(this.config || {}).create();
|
107 | this.configDiff.diff(this.config || {});
|
108 | }
|
109 | this.zone.runOutsideAngular(function () {
|
110 | _this.ro = new ResizeObserver(function (entries, observer) {
|
111 | _this.update();
|
112 | });
|
113 | if (_this.elementRef.nativeElement.children[0]) {
|
114 | _this.ro.observe(_this.elementRef.nativeElement.children[0]);
|
115 | }
|
116 | _this.ro.observe(_this.elementRef.nativeElement);
|
117 | });
|
118 | this.zone.runOutsideAngular(function () {
|
119 | PerfectScrollbarEvents.forEach(function (eventName) {
|
120 | var eventType = eventName.replace(/([A-Z])/g, function (c) { return "-" + c.toLowerCase(); });
|
121 | fromEvent(_this.elementRef.nativeElement, eventType)
|
122 | .pipe(debounceTime(20), takeUntil(_this.ngDestroy))
|
123 | .subscribe(function (event) {
|
124 | _this[eventName].emit(event);
|
125 | });
|
126 | });
|
127 | });
|
128 | }
|
129 | };
|
130 | |
131 |
|
132 |
|
133 | PerfectScrollbarDirective.prototype.ngOnDestroy = |
134 |
|
135 |
|
136 | function () {
|
137 | var _this = this;
|
138 | if (isPlatformBrowser(this.platformId)) {
|
139 | this.ngDestroy.next();
|
140 | this.ngDestroy.complete();
|
141 | if (this.ro) {
|
142 | this.ro.disconnect();
|
143 | }
|
144 | if (this.timeout && typeof window !== 'undefined') {
|
145 | window.clearTimeout(this.timeout);
|
146 | }
|
147 | this.zone.runOutsideAngular(function () {
|
148 | if (_this.instance) {
|
149 | _this.instance.destroy();
|
150 | }
|
151 | });
|
152 | this.instance = null;
|
153 | }
|
154 | };
|
155 | |
156 |
|
157 |
|
158 | PerfectScrollbarDirective.prototype.ngDoCheck = |
159 |
|
160 |
|
161 | function () {
|
162 | if (!this.disabled && this.configDiff && isPlatformBrowser(this.platformId)) {
|
163 | var changes = this.configDiff.diff(this.config || {});
|
164 | if (changes) {
|
165 | this.ngOnDestroy();
|
166 | this.ngOnInit();
|
167 | }
|
168 | }
|
169 | };
|
170 | |
171 |
|
172 |
|
173 |
|
174 | PerfectScrollbarDirective.prototype.ngOnChanges = |
175 |
|
176 |
|
177 |
|
178 | function (changes) {
|
179 | if (changes['disabled'] && !changes['disabled'].isFirstChange() && isPlatformBrowser(this.platformId)) {
|
180 | if (changes['disabled'].currentValue !== changes['disabled'].previousValue) {
|
181 | if (changes['disabled'].currentValue === true) {
|
182 | this.ngOnDestroy();
|
183 | }
|
184 | else if (changes['disabled'].currentValue === false) {
|
185 | this.ngOnInit();
|
186 | }
|
187 | }
|
188 | }
|
189 | };
|
190 | |
191 |
|
192 |
|
193 | PerfectScrollbarDirective.prototype.ps = |
194 |
|
195 |
|
196 | function () {
|
197 | return this.instance;
|
198 | };
|
199 | |
200 |
|
201 |
|
202 | PerfectScrollbarDirective.prototype.update = |
203 |
|
204 |
|
205 | function () {
|
206 | var _this = this;
|
207 | if (typeof window !== 'undefined') {
|
208 | if (this.timeout) {
|
209 | window.clearTimeout(this.timeout);
|
210 | }
|
211 | this.timeout = window.setTimeout(function () {
|
212 | if (!_this.disabled && _this.configDiff) {
|
213 | try {
|
214 | _this.zone.runOutsideAngular(function () {
|
215 | if (_this.instance) {
|
216 | _this.instance.update();
|
217 | }
|
218 | });
|
219 | }
|
220 | catch ( error) {
|
221 |
|
222 | }
|
223 | }
|
224 | }, 0);
|
225 | }
|
226 | };
|
227 | |
228 |
|
229 |
|
230 |
|
231 | PerfectScrollbarDirective.prototype.geometry = |
232 |
|
233 |
|
234 |
|
235 | function (prefix) {
|
236 | if (prefix === void 0) { prefix = 'scroll'; }
|
237 | return new Geometry(this.elementRef.nativeElement[prefix + 'Left'], this.elementRef.nativeElement[prefix + 'Top'], this.elementRef.nativeElement[prefix + 'Width'], this.elementRef.nativeElement[prefix + 'Height']);
|
238 | };
|
239 | |
240 |
|
241 |
|
242 |
|
243 | PerfectScrollbarDirective.prototype.position = |
244 |
|
245 |
|
246 |
|
247 | function (absolute) {
|
248 | if (absolute === void 0) { absolute = false; }
|
249 | if (!absolute && this.instance) {
|
250 | return new Position(this.instance.reach.x || 0, this.instance.reach.y || 0);
|
251 | }
|
252 | else {
|
253 | return new Position(this.elementRef.nativeElement.scrollLeft, this.elementRef.nativeElement.scrollTop);
|
254 | }
|
255 | };
|
256 | |
257 |
|
258 |
|
259 |
|
260 | PerfectScrollbarDirective.prototype.scrollable = |
261 |
|
262 |
|
263 |
|
264 | function (direction) {
|
265 | if (direction === void 0) { direction = 'any'; }
|
266 | var element = this.elementRef.nativeElement;
|
267 | if (direction === 'any') {
|
268 | return element.classList.contains('ps--active-x') ||
|
269 | element.classList.contains('ps--active-y');
|
270 | }
|
271 | else if (direction === 'both') {
|
272 | return element.classList.contains('ps--active-x') &&
|
273 | element.classList.contains('ps--active-y');
|
274 | }
|
275 | else {
|
276 | return element.classList.contains('ps--active-' + direction);
|
277 | }
|
278 | };
|
279 | |
280 |
|
281 |
|
282 |
|
283 |
|
284 |
|
285 | PerfectScrollbarDirective.prototype.scrollTo = |
286 |
|
287 |
|
288 |
|
289 |
|
290 |
|
291 | function (x, y, speed) {
|
292 | if (!this.disabled) {
|
293 | if (y == null && speed == null) {
|
294 | this.animateScrolling('scrollTop', x, speed);
|
295 | }
|
296 | else {
|
297 | if (x != null) {
|
298 | this.animateScrolling('scrollLeft', x, speed);
|
299 | }
|
300 | if (y != null) {
|
301 | this.animateScrolling('scrollTop', y, speed);
|
302 | }
|
303 | }
|
304 | }
|
305 | };
|
306 | |
307 |
|
308 |
|
309 |
|
310 |
|
311 | PerfectScrollbarDirective.prototype.scrollToX = |
312 |
|
313 |
|
314 |
|
315 |
|
316 | function (x, speed) {
|
317 | this.animateScrolling('scrollLeft', x, speed);
|
318 | };
|
319 | |
320 |
|
321 |
|
322 |
|
323 |
|
324 | PerfectScrollbarDirective.prototype.scrollToY = |
325 |
|
326 |
|
327 |
|
328 |
|
329 | function (y, speed) {
|
330 | this.animateScrolling('scrollTop', y, speed);
|
331 | };
|
332 | |
333 |
|
334 |
|
335 |
|
336 |
|
337 | PerfectScrollbarDirective.prototype.scrollToTop = |
338 |
|
339 |
|
340 |
|
341 |
|
342 | function (offset, speed) {
|
343 | this.animateScrolling('scrollTop', (offset || 0), speed);
|
344 | };
|
345 | |
346 |
|
347 |
|
348 |
|
349 |
|
350 | PerfectScrollbarDirective.prototype.scrollToLeft = |
351 |
|
352 |
|
353 |
|
354 |
|
355 | function (offset, speed) {
|
356 | this.animateScrolling('scrollLeft', (offset || 0), speed);
|
357 | };
|
358 | |
359 |
|
360 |
|
361 |
|
362 |
|
363 | PerfectScrollbarDirective.prototype.scrollToRight = |
364 |
|
365 |
|
366 |
|
367 |
|
368 | function (offset, speed) {
|
369 | var left = this.elementRef.nativeElement.scrollWidth -
|
370 | this.elementRef.nativeElement.clientWidth;
|
371 | this.animateScrolling('scrollLeft', left - (offset || 0), speed);
|
372 | };
|
373 | |
374 |
|
375 |
|
376 |
|
377 |
|
378 | PerfectScrollbarDirective.prototype.scrollToBottom = |
379 |
|
380 |
|
381 |
|
382 |
|
383 | function (offset, speed) {
|
384 | var top = this.elementRef.nativeElement.scrollHeight -
|
385 | this.elementRef.nativeElement.clientHeight;
|
386 | this.animateScrolling('scrollTop', top - (offset || 0), speed);
|
387 | };
|
388 | |
389 |
|
390 |
|
391 |
|
392 |
|
393 |
|
394 | PerfectScrollbarDirective.prototype.scrollToElement = |
395 |
|
396 |
|
397 |
|
398 |
|
399 |
|
400 | function (qs, offset, speed) {
|
401 | var element = this.elementRef.nativeElement.querySelector(qs);
|
402 | if (element) {
|
403 | var elementPos = element.getBoundingClientRect();
|
404 | var scrollerPos = this.elementRef.nativeElement.getBoundingClientRect();
|
405 | if (this.elementRef.nativeElement.classList.contains('ps--active-x')) {
|
406 | var currentPos = this.elementRef.nativeElement['scrollLeft'];
|
407 | var position = elementPos.left - scrollerPos.left + currentPos;
|
408 | this.animateScrolling('scrollLeft', position + (offset || 0), speed);
|
409 | }
|
410 | if (this.elementRef.nativeElement.classList.contains('ps--active-y')) {
|
411 | var currentPos = this.elementRef.nativeElement['scrollTop'];
|
412 | var position = elementPos.top - scrollerPos.top + currentPos;
|
413 | this.animateScrolling('scrollTop', position + (offset || 0), speed);
|
414 | }
|
415 | }
|
416 | };
|
417 | |
418 |
|
419 |
|
420 |
|
421 |
|
422 |
|
423 | PerfectScrollbarDirective.prototype.animateScrolling = |
424 |
|
425 |
|
426 |
|
427 |
|
428 |
|
429 | function (target, value, speed) {
|
430 | var _this = this;
|
431 | if (!speed || typeof window === 'undefined') {
|
432 | var oldValue = this.elementRef.nativeElement[target];
|
433 | this.elementRef.nativeElement[target] = value;
|
434 | if (this.instance && value !== oldValue) {
|
435 | this.instance.update();
|
436 | }
|
437 | }
|
438 | else if (value !== this.elementRef.nativeElement[target]) {
|
439 | var newValue_1 = 0;
|
440 | var scrollCount_1 = 0;
|
441 | var oldTimestamp_1 = performance.now();
|
442 | var oldValue_1 = this.elementRef.nativeElement[target];
|
443 | var cosParameter_1 = (oldValue_1 - value) / 2;
|
444 | var step_1 = function (newTimestamp) {
|
445 | scrollCount_1 += Math.PI / (speed / (newTimestamp - oldTimestamp_1));
|
446 | newValue_1 = Math.round(value + cosParameter_1 + cosParameter_1 * Math.cos(scrollCount_1));
|
447 |
|
448 | if (_this.elementRef.nativeElement[target] === oldValue_1) {
|
449 | if (scrollCount_1 >= Math.PI) {
|
450 | _this.animateScrolling(target, value, 0);
|
451 | }
|
452 | else {
|
453 | _this.elementRef.nativeElement[target] = newValue_1;
|
454 |
|
455 |
|
456 | oldValue_1 = _this.elementRef.nativeElement[target];
|
457 | if (_this.instance) {
|
458 | _this.instance.update();
|
459 | }
|
460 | oldTimestamp_1 = newTimestamp;
|
461 | window.requestAnimationFrame(step_1);
|
462 | }
|
463 | }
|
464 | };
|
465 | window.requestAnimationFrame(step_1);
|
466 | }
|
467 | };
|
468 | PerfectScrollbarDirective.decorators = [
|
469 | { type: Directive, args: [{
|
470 | selector: '[perfectScrollbar]',
|
471 | exportAs: 'ngxPerfectScrollbar'
|
472 | },] }
|
473 | ];
|
474 |
|
475 | PerfectScrollbarDirective.ctorParameters = function () { return [
|
476 | { type: NgZone, },
|
477 | { type: KeyValueDiffers, },
|
478 | { type: ElementRef, },
|
479 | { type: Object, decorators: [{ type: Inject, args: [PLATFORM_ID,] },] },
|
480 | { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [PERFECT_SCROLLBAR_CONFIG,] },] },
|
481 | ]; };
|
482 | PerfectScrollbarDirective.propDecorators = {
|
483 | "disabled": [{ type: Input },],
|
484 | "config": [{ type: Input, args: ['perfectScrollbar',] },],
|
485 | "psScrollY": [{ type: Output },],
|
486 | "psScrollX": [{ type: Output },],
|
487 | "psScrollUp": [{ type: Output },],
|
488 | "psScrollDown": [{ type: Output },],
|
489 | "psScrollLeft": [{ type: Output },],
|
490 | "psScrollRight": [{ type: Output },],
|
491 | "psYReachEnd": [{ type: Output },],
|
492 | "psYReachStart": [{ type: Output },],
|
493 | "psXReachEnd": [{ type: Output },],
|
494 | "psXReachStart": [{ type: Output },],
|
495 | };
|
496 | return PerfectScrollbarDirective;
|
497 | }());
|
498 |
|
499 |
|
500 |
|
501 |
|
502 |
|
503 | var PerfectScrollbarComponent = (function () {
|
504 | function PerfectScrollbarComponent(zone, cdRef, platformId) {
|
505 | this.zone = zone;
|
506 | this.cdRef = cdRef;
|
507 | this.platformId = platformId;
|
508 | this.states = {};
|
509 | this.indicatorX = false;
|
510 | this.indicatorY = false;
|
511 | this.interaction = false;
|
512 | this.scrollPositionX = 0;
|
513 | this.scrollPositionY = 0;
|
514 | this.scrollDirectionX = 0;
|
515 | this.scrollDirectionY = 0;
|
516 | this.usePropagationX = false;
|
517 | this.usePropagationY = false;
|
518 | this.allowPropagationX = false;
|
519 | this.allowPropagationY = false;
|
520 | this.stateTimeout = null;
|
521 | this.ngDestroy = new Subject();
|
522 | this.stateUpdate = new Subject();
|
523 | this.disabled = false;
|
524 | this.usePSClass = true;
|
525 | this.autoPropagation = false;
|
526 | this.scrollIndicators = false;
|
527 | this.psScrollY = new EventEmitter();
|
528 | this.psScrollX = new EventEmitter();
|
529 | this.psScrollUp = new EventEmitter();
|
530 | this.psScrollDown = new EventEmitter();
|
531 | this.psScrollLeft = new EventEmitter();
|
532 | this.psScrollRight = new EventEmitter();
|
533 | this.psYReachEnd = new EventEmitter();
|
534 | this.psYReachStart = new EventEmitter();
|
535 | this.psXReachEnd = new EventEmitter();
|
536 | this.psXReachStart = new EventEmitter();
|
537 | }
|
538 | |
539 |
|
540 |
|
541 | PerfectScrollbarComponent.prototype.ngOnInit = |
542 |
|
543 |
|
544 | function () {
|
545 | var _this = this;
|
546 | if (isPlatformBrowser(this.platformId)) {
|
547 | this.stateUpdate
|
548 | .pipe(takeUntil(this.ngDestroy), distinctUntilChanged(function (a, b) { return (a === b && !_this.stateTimeout); }))
|
549 | .subscribe(function (state) {
|
550 | if (_this.stateTimeout && typeof window !== 'undefined') {
|
551 | window.clearTimeout(_this.stateTimeout);
|
552 | _this.stateTimeout = null;
|
553 | }
|
554 | if (state === 'x' || state === 'y') {
|
555 | _this.interaction = false;
|
556 | if (state === 'x') {
|
557 | _this.indicatorX = false;
|
558 | _this.states.left = false;
|
559 | _this.states.right = false;
|
560 | if (_this.autoPropagation && _this.usePropagationX) {
|
561 | _this.allowPropagationX = false;
|
562 | }
|
563 | }
|
564 | else if (state === 'y') {
|
565 | _this.indicatorY = false;
|
566 | _this.states.top = false;
|
567 | _this.states.bottom = false;
|
568 | if (_this.autoPropagation && _this.usePropagationY) {
|
569 | _this.allowPropagationY = false;
|
570 | }
|
571 | }
|
572 | }
|
573 | else {
|
574 | if (state === 'left' || state === 'right') {
|
575 | _this.states.left = false;
|
576 | _this.states.right = false;
|
577 | _this.states[state] = true;
|
578 | if (_this.autoPropagation && _this.usePropagationX) {
|
579 | _this.indicatorX = true;
|
580 | }
|
581 | }
|
582 | else if (state === 'top' || state === 'bottom') {
|
583 | _this.states.top = false;
|
584 | _this.states.bottom = false;
|
585 | _this.states[state] = true;
|
586 | if (_this.autoPropagation && _this.usePropagationY) {
|
587 | _this.indicatorY = true;
|
588 | }
|
589 | }
|
590 | if (_this.autoPropagation && typeof window !== 'undefined') {
|
591 | _this.stateTimeout = window.setTimeout(function () {
|
592 | _this.indicatorX = false;
|
593 | _this.indicatorY = false;
|
594 | _this.stateTimeout = null;
|
595 | if (_this.interaction && (_this.states.left || _this.states.right)) {
|
596 | _this.allowPropagationX = true;
|
597 | }
|
598 | if (_this.interaction && (_this.states.top || _this.states.bottom)) {
|
599 | _this.allowPropagationY = true;
|
600 | }
|
601 | _this.cdRef.markForCheck();
|
602 | }, 500);
|
603 | }
|
604 | }
|
605 | _this.cdRef.markForCheck();
|
606 | _this.cdRef.detectChanges();
|
607 | });
|
608 | this.zone.runOutsideAngular(function () {
|
609 | if (_this.directiveRef) {
|
610 | var element = _this.directiveRef.elementRef.nativeElement;
|
611 | fromEvent(element, 'wheel')
|
612 | .pipe(takeUntil(_this.ngDestroy))
|
613 | .subscribe(function (event) {
|
614 | if (!_this.disabled && _this.autoPropagation) {
|
615 | var scrollDeltaX = event.deltaX;
|
616 | var scrollDeltaY = event.deltaY;
|
617 | _this.checkPropagation(event, scrollDeltaX, scrollDeltaY);
|
618 | }
|
619 | });
|
620 | fromEvent(element, 'touchmove')
|
621 | .pipe(takeUntil(_this.ngDestroy))
|
622 | .subscribe(function (event) {
|
623 | if (!_this.disabled && _this.autoPropagation) {
|
624 | var scrollPositionX = event.touches[0].clientX;
|
625 | var scrollPositionY = event.touches[0].clientY;
|
626 | var scrollDeltaX = scrollPositionX - _this.scrollPositionX;
|
627 | var scrollDeltaY = scrollPositionY - _this.scrollPositionY;
|
628 | _this.checkPropagation(event, scrollDeltaX, scrollDeltaY);
|
629 | _this.scrollPositionX = scrollPositionX;
|
630 | _this.scrollPositionY = scrollPositionY;
|
631 | }
|
632 | });
|
633 | merge(fromEvent(element, 'ps-scroll-x')
|
634 | .pipe(map(function (event) { return event.state = 'x'; })), fromEvent(element, 'ps-scroll-y')
|
635 | .pipe(map(function (event) { return event.state = 'y'; })), fromEvent(element, 'ps-x-reach-end')
|
636 | .pipe(map(function (event) { return event.state = 'right'; })), fromEvent(element, 'ps-y-reach-end')
|
637 | .pipe(map(function (event) { return event.state = 'bottom'; })), fromEvent(element, 'ps-x-reach-start')
|
638 | .pipe(map(function (event) { return event.state = 'left'; })), fromEvent(element, 'ps-y-reach-start')
|
639 | .pipe(map(function (event) { return event.state = 'top'; })))
|
640 | .pipe(takeUntil(_this.ngDestroy))
|
641 | .subscribe(function (event) {
|
642 | if (!_this.disabled && (_this.autoPropagation || _this.scrollIndicators)) {
|
643 | _this.stateUpdate.next(event.state);
|
644 | }
|
645 | });
|
646 | }
|
647 | });
|
648 | window.setTimeout(function () {
|
649 | PerfectScrollbarEvents.forEach(function (eventName) {
|
650 | if (_this.directiveRef) {
|
651 | _this.directiveRef[eventName] = _this[eventName];
|
652 | }
|
653 | });
|
654 | }, 0);
|
655 | }
|
656 | };
|
657 | |
658 |
|
659 |
|
660 | PerfectScrollbarComponent.prototype.ngOnDestroy = |
661 |
|
662 |
|
663 | function () {
|
664 | if (isPlatformBrowser(this.platformId)) {
|
665 | this.ngDestroy.next();
|
666 | this.ngDestroy.unsubscribe();
|
667 | if (this.stateTimeout && typeof window !== 'undefined') {
|
668 | window.clearTimeout(this.stateTimeout);
|
669 | }
|
670 | }
|
671 | };
|
672 | |
673 |
|
674 |
|
675 | PerfectScrollbarComponent.prototype.ngDoCheck = |
676 |
|
677 |
|
678 | function () {
|
679 | if (isPlatformBrowser(this.platformId)) {
|
680 | if (!this.disabled && this.autoPropagation && this.directiveRef) {
|
681 | var element = this.directiveRef.elementRef.nativeElement;
|
682 | this.usePropagationX = element.classList.contains('ps--active-x');
|
683 | this.usePropagationY = element.classList.contains('ps--active-y');
|
684 | }
|
685 | }
|
686 | };
|
687 | |
688 |
|
689 |
|
690 |
|
691 |
|
692 |
|
693 | PerfectScrollbarComponent.prototype.checkPropagation = |
694 |
|
695 |
|
696 |
|
697 |
|
698 |
|
699 | function (event, deltaX, deltaY) {
|
700 | this.interaction = true;
|
701 | var scrollDirectionX = (deltaX < 0) ? -1 : 1;
|
702 | var scrollDirectionY = (deltaY < 0) ? -1 : 1;
|
703 | if ((this.usePropagationX && this.usePropagationY) ||
|
704 | (this.usePropagationX && (!this.allowPropagationX ||
|
705 | (this.scrollDirectionX !== scrollDirectionX))) ||
|
706 | (this.usePropagationY && (!this.allowPropagationY ||
|
707 | (this.scrollDirectionY !== scrollDirectionY)))) {
|
708 | event.preventDefault();
|
709 | event.stopPropagation();
|
710 | }
|
711 | if (!!deltaX) {
|
712 | this.scrollDirectionX = scrollDirectionX;
|
713 | }
|
714 | if (!!deltaY) {
|
715 | this.scrollDirectionY = scrollDirectionY;
|
716 | }
|
717 | this.stateUpdate.next('interaction');
|
718 | this.cdRef.detectChanges();
|
719 | };
|
720 | PerfectScrollbarComponent.decorators = [
|
721 | { type: Component, args: [{
|
722 | selector: 'perfect-scrollbar',
|
723 | exportAs: 'ngxPerfectScrollbar',
|
724 | template: "<div style=\"position: static;\" [class.ps]=\"usePSClass\" [perfectScrollbar]=\"config\" [disabled]=\"disabled\">\n <div class=\"ps-content\">\n <ng-content></ng-content>\n </div>\n\n <div *ngIf=\"scrollIndicators\" class=\"ps-overlay\" [class.ps-at-top]=\"states.top\" [class.ps-at-left]=\"states.left\" [class.ps-at-right]=\"states.right\" [class.ps-at-bottom]=\"states.bottom\">\n <div class=\"ps-indicator-top\" [class.ps-indicator-show]=\"indicatorY && interaction\"></div>\n <div class=\"ps-indicator-left\" [class.ps-indicator-show]=\"indicatorX && interaction\"></div>\n <div class=\"ps-indicator-right\" [class.ps-indicator-show]=\"indicatorX && interaction\"></div>\n <div class=\"ps-indicator-bottom\" [class.ps-indicator-show]=\"indicatorY && interaction\"></div>\n </div>\n</div>\n",
|
725 | encapsulation: ViewEncapsulation.None,
|
726 | styles: ["/*\n * Container style\n */\n.ps {\n overflow: hidden !important;\n overflow-anchor: none;\n -ms-overflow-style: none;\n touch-action: auto;\n -ms-touch-action: auto; }\n\n/*\n * Scrollbar rail styles\n */\n.ps__rail-x {\n display: none;\n opacity: 0;\n transition: background-color .2s linear, opacity .2s linear;\n -webkit-transition: background-color .2s linear, opacity .2s linear;\n height: 15px;\n /* there must be 'bottom' or 'top' for ps__rail-x */\n bottom: 0px;\n /* please don't change 'position' */\n position: absolute; }\n\n.ps__rail-y {\n display: none;\n opacity: 0;\n transition: background-color .2s linear, opacity .2s linear;\n -webkit-transition: background-color .2s linear, opacity .2s linear;\n width: 15px;\n /* there must be 'right' or 'left' for ps__rail-y */\n right: 0;\n /* please don't change 'position' */\n position: absolute; }\n\n.ps--active-x > .ps__rail-x,\n.ps--active-y > .ps__rail-y {\n display: block;\n background-color: transparent; }\n\n.ps:hover > .ps__rail-x,\n.ps:hover > .ps__rail-y,\n.ps--focus > .ps__rail-x,\n.ps--focus > .ps__rail-y,\n.ps--scrolling-x > .ps__rail-x,\n.ps--scrolling-y > .ps__rail-y {\n opacity: 0.6; }\n\n.ps__rail-x:hover,\n.ps__rail-y:hover,\n.ps__rail-x:focus,\n.ps__rail-y:focus {\n background-color: #eee;\n opacity: 0.9; }\n\n/*\n * Scrollbar thumb styles\n */\n.ps__thumb-x {\n background-color: #aaa;\n border-radius: 6px;\n transition: background-color .2s linear, height .2s ease-in-out;\n -webkit-transition: background-color .2s linear, height .2s ease-in-out;\n height: 6px;\n /* there must be 'bottom' for ps__thumb-x */\n bottom: 2px;\n /* please don't change 'position' */\n position: absolute; }\n\n.ps__thumb-y {\n background-color: #aaa;\n border-radius: 6px;\n transition: background-color .2s linear, width .2s ease-in-out;\n -webkit-transition: background-color .2s linear, width .2s ease-in-out;\n width: 6px;\n /* there must be 'right' for ps__thumb-y */\n right: 2px;\n /* please don't change 'position' */\n position: absolute; }\n\n.ps__rail-x:hover > .ps__thumb-x,\n.ps__rail-x:focus > .ps__thumb-x {\n background-color: #999;\n height: 11px; }\n\n.ps__rail-y:hover > .ps__thumb-y,\n.ps__rail-y:focus > .ps__thumb-y {\n background-color: #999;\n width: 11px; }\n\n/* MS supports */\n@supports (-ms-overflow-style: none) {\n .ps {\n overflow: auto !important; } }\n\n@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {\n .ps {\n overflow: auto !important; } }\n\n/*\n TODO: Remove important flags after this bug if fixed:\n https://github.com/angular/flex-layout/issues/381\n*/\nperfect-scrollbar {\n position: relative;\n display: block;\n overflow: hidden;\n width: 100%;\n height: 100%;\n max-width: 100%;\n max-height: 100%;\n /* stylelint-disable */\n /* stylelint-enable */ }\n perfect-scrollbar[hidden] {\n display: none; }\n perfect-scrollbar[fxflex] {\n display: flex;\n flex-direction: column;\n -webkit-box-orient: column;\n -webkit-box-direction: column;\n height: auto;\n min-width: 0;\n min-height: 0; }\n perfect-scrollbar[fxflex] > .ps {\n flex: 1 1 auto;\n -ms-flex: 1 1 auto;\n -webkit-box-flex: 1;\n width: auto;\n height: auto;\n min-width: 0;\n min-height: 0; }\n perfect-scrollbar[fxlayout] > .ps,\n perfect-scrollbar[fxlayout] > .ps > .ps-content {\n display: flex;\n flex: 1 1 auto;\n -ms-flex: 1 1 auto;\n -webkit-box-flex: 1;\n align-item: inherit;\n place-content: inherit;\n -webkit-box-pack: inherit;\n -webkit-box-align: inherit;\n flex-direction: inherit;\n -webkit-box-orient: inherit;\n -webkit-box-direction: inherit;\n width: 100%;\n height: 100%; }\n perfect-scrollbar[fxlayout=\"row\"] > .ps,\n perfect-scrollbar[fxlayout=\"row\"] > .ps > .ps-content {\n flex-direction: row !important;\n -webkit-box-orient: row !important;\n -webkit-box-direction: row !important; }\n perfect-scrollbar[fxlayout=\"column\"] > .ps,\n perfect-scrollbar[fxlayout=\"column\"] > .ps > .ps-content {\n flex-direction: column !important;\n -webkit-box-orient: column !important;\n -webkit-box-direction: column !important; }\n perfect-scrollbar > .ps {\n position: static;\n display: block;\n width: inherit;\n height: inherit;\n max-width: inherit;\n max-height: inherit; }\n perfect-scrollbar > .ps > .ps-overlay {\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n display: block;\n overflow: hidden;\n pointer-events: none; }\n perfect-scrollbar > .ps > .ps-overlay .ps-indicator-top,\n perfect-scrollbar > .ps > .ps-overlay .ps-indicator-left,\n perfect-scrollbar > .ps > .ps-overlay .ps-indicator-right,\n perfect-scrollbar > .ps > .ps-overlay .ps-indicator-bottom {\n position: absolute;\n opacity: 0;\n transition: opacity 300ms ease-in-out; }\n perfect-scrollbar > .ps > .ps-overlay .ps-indicator-top,\n perfect-scrollbar > .ps > .ps-overlay .ps-indicator-bottom {\n left: 0;\n min-width: 100%;\n min-height: 24px; }\n perfect-scrollbar > .ps > .ps-overlay .ps-indicator-left,\n perfect-scrollbar > .ps > .ps-overlay .ps-indicator-right {\n top: 0;\n min-width: 24px;\n min-height: 100%; }\n perfect-scrollbar > .ps > .ps-overlay .ps-indicator-top {\n top: 0; }\n perfect-scrollbar > .ps > .ps-overlay .ps-indicator-left {\n left: 0; }\n perfect-scrollbar > .ps > .ps-overlay .ps-indicator-right {\n right: 0; }\n perfect-scrollbar > .ps > .ps-overlay .ps-indicator-bottom {\n bottom: 0; }\n perfect-scrollbar > .ps.ps--active-y > .ps__rail-y {\n top: 0 !important;\n right: 0 !important;\n left: auto !important;\n width: 10px;\n cursor: default;\n transition: width 200ms linear, opacity 200ms linear, background-color 200ms linear; }\n perfect-scrollbar > .ps.ps--active-y > .ps__rail-y:hover {\n width: 15px; }\n perfect-scrollbar > .ps.ps--active-x > .ps__rail-x {\n top: auto !important;\n bottom: 0 !important;\n left: 0 !important;\n height: 10px;\n cursor: default;\n transition: height 200ms linear, opacity 200ms linear, background-color 200ms linear; }\n perfect-scrollbar > .ps.ps--active-x > .ps__rail-x:hover {\n height: 15px; }\n perfect-scrollbar > .ps.ps--active-x.ps--active-y > .ps__rail-y {\n margin: 0 0 10px; }\n perfect-scrollbar > .ps.ps--active-x.ps--active-y > .ps__rail-x {\n margin: 0 10px 0 0; }\n perfect-scrollbar > .ps.ps--scrolling-y > .ps__rail-y {\n opacity: 0.9;\n background-color: #eee; }\n perfect-scrollbar > .ps.ps--scrolling-x > .ps__rail-x {\n opacity: 0.9;\n background-color: #eee; }\n perfect-scrollbar.ps-show-always > .ps.ps--active-y > .ps__rail-y {\n opacity: 0.6; }\n perfect-scrollbar.ps-show-always > .ps.ps--active-x > .ps__rail-x {\n opacity: 0.6; }\n perfect-scrollbar.ps-show-active > .ps.ps--active-y > .ps-overlay:not(.ps-at-top) .ps-indicator-top {\n opacity: 1;\n background: linear-gradient(to bottom, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 100%); }\n perfect-scrollbar.ps-show-active > .ps.ps--active-y > .ps-overlay:not(.ps-at-bottom) .ps-indicator-bottom {\n opacity: 1;\n background: linear-gradient(to top, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 100%); }\n perfect-scrollbar.ps-show-active > .ps.ps--active-x > .ps-overlay:not(.ps-at-left) .ps-indicator-left {\n opacity: 1;\n background: linear-gradient(to right, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 100%); }\n perfect-scrollbar.ps-show-active > .ps.ps--active-x > .ps-overlay:not(.ps-at-right) .ps-indicator-right {\n opacity: 1;\n background: linear-gradient(to left, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 100%); }\n perfect-scrollbar.ps-show-active.ps-show-limits > .ps.ps--active-y > .ps-overlay.ps-at-top .ps-indicator-top {\n background: linear-gradient(to bottom, rgba(170, 170, 170, 0.5) 0%, rgba(170, 170, 170, 0) 100%); }\n perfect-scrollbar.ps-show-active.ps-show-limits > .ps.ps--active-y > .ps-overlay.ps-at-top .ps-indicator-top.ps-indicator-show {\n opacity: 1; }\n perfect-scrollbar.ps-show-active.ps-show-limits > .ps.ps--active-y > .ps-overlay.ps-at-bottom .ps-indicator-bottom {\n background: linear-gradient(to top, rgba(170, 170, 170, 0.5) 0%, rgba(170, 170, 170, 0) 100%); }\n perfect-scrollbar.ps-show-active.ps-show-limits > .ps.ps--active-y > .ps-overlay.ps-at-bottom .ps-indicator-bottom.ps-indicator-show {\n opacity: 1; }\n perfect-scrollbar.ps-show-active.ps-show-limits > .ps.ps--active-x > .ps-overlay.ps-at-left .ps-indicator-left {\n background: linear-gradient(to right, rgba(170, 170, 170, 0.5) 0%, rgba(170, 170, 170, 0) 100%); }\n perfect-scrollbar.ps-show-active.ps-show-limits > .ps.ps--active-x > .ps-overlay.ps-at-left .ps-indicator-left.ps-indicator-show {\n opacity: 1; }\n perfect-scrollbar.ps-show-active.ps-show-limits > .ps.ps--active-x > .ps-overlay.ps-at-right .ps-indicator-right {\n background: linear-gradient(to left, rgba(170, 170, 170, 0.5) 0%, rgba(170, 170, 170, 0) 100%); }\n perfect-scrollbar.ps-show-active.ps-show-limits > .ps.ps--active-x > .ps-overlay.ps-at-right .ps-indicator-right.ps-indicator-show {\n opacity: 1; }\n\n/*# sourceMappingURL=perfect-scrollbar.component.css.map */"]
|
727 | }] }
|
728 | ];
|
729 |
|
730 | PerfectScrollbarComponent.ctorParameters = function () { return [
|
731 | { type: NgZone, },
|
732 | { type: ChangeDetectorRef, },
|
733 | { type: Object, decorators: [{ type: Inject, args: [PLATFORM_ID,] },] },
|
734 | ]; };
|
735 | PerfectScrollbarComponent.propDecorators = {
|
736 | "disabled": [{ type: Input },],
|
737 | "usePSClass": [{ type: Input },],
|
738 | "autoPropagation": [{ type: HostBinding, args: ['class.ps-show-limits',] }, { type: Input },],
|
739 | "scrollIndicators": [{ type: HostBinding, args: ['class.ps-show-active',] }, { type: Input },],
|
740 | "config": [{ type: Input },],
|
741 | "psScrollY": [{ type: Output },],
|
742 | "psScrollX": [{ type: Output },],
|
743 | "psScrollUp": [{ type: Output },],
|
744 | "psScrollDown": [{ type: Output },],
|
745 | "psScrollLeft": [{ type: Output },],
|
746 | "psScrollRight": [{ type: Output },],
|
747 | "psYReachEnd": [{ type: Output },],
|
748 | "psYReachStart": [{ type: Output },],
|
749 | "psXReachEnd": [{ type: Output },],
|
750 | "psXReachStart": [{ type: Output },],
|
751 | "directiveRef": [{ type: ViewChild, args: [PerfectScrollbarDirective,] },],
|
752 | };
|
753 | return PerfectScrollbarComponent;
|
754 | }());
|
755 |
|
756 |
|
757 |
|
758 |
|
759 |
|
760 | var PerfectScrollbarModule = (function () {
|
761 | function PerfectScrollbarModule() {
|
762 | }
|
763 | PerfectScrollbarModule.decorators = [
|
764 | { type: NgModule, args: [{
|
765 | imports: [CommonModule],
|
766 | declarations: [PerfectScrollbarComponent, PerfectScrollbarDirective],
|
767 | exports: [CommonModule, PerfectScrollbarComponent, PerfectScrollbarDirective]
|
768 | },] }
|
769 | ];
|
770 | return PerfectScrollbarModule;
|
771 | }());
|
772 |
|
773 |
|
774 |
|
775 |
|
776 |
|
777 |
|
778 |
|
779 |
|
780 |
|
781 |
|
782 |
|
783 | export { PerfectScrollbarComponent, PerfectScrollbarDirective, Geometry, Position, PERFECT_SCROLLBAR_CONFIG, PerfectScrollbarConfig, PerfectScrollbarModule };
|
784 |
|