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