source: trip-planner-front/node_modules/@angular/cdk/esm2015/scrolling/scrollable.js@ bdd6491

Last change on this file since bdd6491 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 22.2 KB
Line 
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8import { Directionality } from '@angular/cdk/bidi';
9import { getRtlScrollAxisType, supportsScrollBehavior } from '@angular/cdk/platform';
10import { Directive, ElementRef, NgZone, Optional } from '@angular/core';
11import { fromEvent, Observable, Subject } from 'rxjs';
12import { takeUntil } from 'rxjs/operators';
13import { ScrollDispatcher } from './scroll-dispatcher';
14/**
15 * Sends an event when the directive's element is scrolled. Registers itself with the
16 * ScrollDispatcher service to include itself as part of its collection of scrolling events that it
17 * can be listened to through the service.
18 */
19export class CdkScrollable {
20 constructor(elementRef, scrollDispatcher, ngZone, dir) {
21 this.elementRef = elementRef;
22 this.scrollDispatcher = scrollDispatcher;
23 this.ngZone = ngZone;
24 this.dir = dir;
25 this._destroyed = new Subject();
26 this._elementScrolled = new Observable((observer) => this.ngZone.runOutsideAngular(() => fromEvent(this.elementRef.nativeElement, 'scroll').pipe(takeUntil(this._destroyed))
27 .subscribe(observer)));
28 }
29 ngOnInit() {
30 this.scrollDispatcher.register(this);
31 }
32 ngOnDestroy() {
33 this.scrollDispatcher.deregister(this);
34 this._destroyed.next();
35 this._destroyed.complete();
36 }
37 /** Returns observable that emits when a scroll event is fired on the host element. */
38 elementScrolled() {
39 return this._elementScrolled;
40 }
41 /** Gets the ElementRef for the viewport. */
42 getElementRef() {
43 return this.elementRef;
44 }
45 /**
46 * Scrolls to the specified offsets. This is a normalized version of the browser's native scrollTo
47 * method, since browsers are not consistent about what scrollLeft means in RTL. For this method
48 * left and right always refer to the left and right side of the scrolling container irrespective
49 * of the layout direction. start and end refer to left and right in an LTR context and vice-versa
50 * in an RTL context.
51 * @param options specified the offsets to scroll to.
52 */
53 scrollTo(options) {
54 const el = this.elementRef.nativeElement;
55 const isRtl = this.dir && this.dir.value == 'rtl';
56 // Rewrite start & end offsets as right or left offsets.
57 if (options.left == null) {
58 options.left = isRtl ? options.end : options.start;
59 }
60 if (options.right == null) {
61 options.right = isRtl ? options.start : options.end;
62 }
63 // Rewrite the bottom offset as a top offset.
64 if (options.bottom != null) {
65 options.top =
66 el.scrollHeight - el.clientHeight - options.bottom;
67 }
68 // Rewrite the right offset as a left offset.
69 if (isRtl && getRtlScrollAxisType() != 0 /* NORMAL */) {
70 if (options.left != null) {
71 options.right =
72 el.scrollWidth - el.clientWidth - options.left;
73 }
74 if (getRtlScrollAxisType() == 2 /* INVERTED */) {
75 options.left = options.right;
76 }
77 else if (getRtlScrollAxisType() == 1 /* NEGATED */) {
78 options.left = options.right ? -options.right : options.right;
79 }
80 }
81 else {
82 if (options.right != null) {
83 options.left =
84 el.scrollWidth - el.clientWidth - options.right;
85 }
86 }
87 this._applyScrollToOptions(options);
88 }
89 _applyScrollToOptions(options) {
90 const el = this.elementRef.nativeElement;
91 if (supportsScrollBehavior()) {
92 el.scrollTo(options);
93 }
94 else {
95 if (options.top != null) {
96 el.scrollTop = options.top;
97 }
98 if (options.left != null) {
99 el.scrollLeft = options.left;
100 }
101 }
102 }
103 /**
104 * Measures the scroll offset relative to the specified edge of the viewport. This method can be
105 * used instead of directly checking scrollLeft or scrollTop, since browsers are not consistent
106 * about what scrollLeft means in RTL. The values returned by this method are normalized such that
107 * left and right always refer to the left and right side of the scrolling container irrespective
108 * of the layout direction. start and end refer to left and right in an LTR context and vice-versa
109 * in an RTL context.
110 * @param from The edge to measure from.
111 */
112 measureScrollOffset(from) {
113 const LEFT = 'left';
114 const RIGHT = 'right';
115 const el = this.elementRef.nativeElement;
116 if (from == 'top') {
117 return el.scrollTop;
118 }
119 if (from == 'bottom') {
120 return el.scrollHeight - el.clientHeight - el.scrollTop;
121 }
122 // Rewrite start & end as left or right offsets.
123 const isRtl = this.dir && this.dir.value == 'rtl';
124 if (from == 'start') {
125 from = isRtl ? RIGHT : LEFT;
126 }
127 else if (from == 'end') {
128 from = isRtl ? LEFT : RIGHT;
129 }
130 if (isRtl && getRtlScrollAxisType() == 2 /* INVERTED */) {
131 // For INVERTED, scrollLeft is (scrollWidth - clientWidth) when scrolled all the way left and
132 // 0 when scrolled all the way right.
133 if (from == LEFT) {
134 return el.scrollWidth - el.clientWidth - el.scrollLeft;
135 }
136 else {
137 return el.scrollLeft;
138 }
139 }
140 else if (isRtl && getRtlScrollAxisType() == 1 /* NEGATED */) {
141 // For NEGATED, scrollLeft is -(scrollWidth - clientWidth) when scrolled all the way left and
142 // 0 when scrolled all the way right.
143 if (from == LEFT) {
144 return el.scrollLeft + el.scrollWidth - el.clientWidth;
145 }
146 else {
147 return -el.scrollLeft;
148 }
149 }
150 else {
151 // For NORMAL, as well as non-RTL contexts, scrollLeft is 0 when scrolled all the way left and
152 // (scrollWidth - clientWidth) when scrolled all the way right.
153 if (from == LEFT) {
154 return el.scrollLeft;
155 }
156 else {
157 return el.scrollWidth - el.clientWidth - el.scrollLeft;
158 }
159 }
160 }
161}
162CdkScrollable.decorators = [
163 { type: Directive, args: [{
164 selector: '[cdk-scrollable], [cdkScrollable]'
165 },] }
166];
167CdkScrollable.ctorParameters = () => [
168 { type: ElementRef },
169 { type: ScrollDispatcher },
170 { type: NgZone },
171 { type: Directionality, decorators: [{ type: Optional }] }
172];
173//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2Nyb2xsYWJsZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3NyYy9jZGsvc2Nyb2xsaW5nL3Njcm9sbGFibGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBRUgsT0FBTyxFQUFDLGNBQWMsRUFBQyxNQUFNLG1CQUFtQixDQ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