UNPKG

78.5 kBJavaScriptView Raw
1import { coerceNumberProperty, coerceElement, coerceBooleanProperty } from '@angular/cdk/coercion';
2import * as i0 from '@angular/core';
3import { InjectionToken, forwardRef, Directive, Input, Injectable, Optional, Inject, inject, Component, ViewEncapsulation, ChangeDetectionStrategy, Output, ViewChild, SkipSelf, ElementRef, NgModule } from '@angular/core';
4import { Subject, of, Observable, fromEvent, animationFrameScheduler, asapScheduler, Subscription, isObservable } from 'rxjs';
5import { distinctUntilChanged, auditTime, filter, takeUntil, startWith, pairwise, switchMap, shareReplay } from 'rxjs/operators';
6import * as i1 from '@angular/cdk/platform';
7import { getRtlScrollAxisType, supportsScrollBehavior, Platform } from '@angular/cdk/platform';
8import { DOCUMENT } from '@angular/common';
9import * as i2 from '@angular/cdk/bidi';
10import { BidiModule } from '@angular/cdk/bidi';
11import * as i2$1 from '@angular/cdk/collections';
12import { isDataSource, ArrayDataSource, _VIEW_REPEATER_STRATEGY, _RecycleViewRepeaterStrategy } from '@angular/cdk/collections';
13
14/** The injection token used to specify the virtual scrolling strategy. */
15const VIRTUAL_SCROLL_STRATEGY = new InjectionToken('VIRTUAL_SCROLL_STRATEGY');
16
17/** Virtual scrolling strategy for lists with items of known fixed size. */
18class FixedSizeVirtualScrollStrategy {
19 /**
20 * @param itemSize The size of the items in the virtually scrolling list.
21 * @param minBufferPx The minimum amount of buffer (in pixels) before needing to render more
22 * @param maxBufferPx The amount of buffer (in pixels) to render when rendering more.
23 */
24 constructor(itemSize, minBufferPx, maxBufferPx) {
25 this._scrolledIndexChange = new Subject();
26 /** @docs-private Implemented as part of VirtualScrollStrategy. */
27 this.scrolledIndexChange = this._scrolledIndexChange.pipe(distinctUntilChanged());
28 /** The attached viewport. */
29 this._viewport = null;
30 this._itemSize = itemSize;
31 this._minBufferPx = minBufferPx;
32 this._maxBufferPx = maxBufferPx;
33 }
34 /**
35 * Attaches this scroll strategy to a viewport.
36 * @param viewport The viewport to attach this strategy to.
37 */
38 attach(viewport) {
39 this._viewport = viewport;
40 this._updateTotalContentSize();
41 this._updateRenderedRange();
42 }
43 /** Detaches this scroll strategy from the currently attached viewport. */
44 detach() {
45 this._scrolledIndexChange.complete();
46 this._viewport = null;
47 }
48 /**
49 * Update the item size and buffer size.
50 * @param itemSize The size of the items in the virtually scrolling list.
51 * @param minBufferPx The minimum amount of buffer (in pixels) before needing to render more
52 * @param maxBufferPx The amount of buffer (in pixels) to render when rendering more.
53 */
54 updateItemAndBufferSize(itemSize, minBufferPx, maxBufferPx) {
55 if (maxBufferPx < minBufferPx && (typeof ngDevMode === 'undefined' || ngDevMode)) {
56 throw Error('CDK virtual scroll: maxBufferPx must be greater than or equal to minBufferPx');
57 }
58 this._itemSize = itemSize;
59 this._minBufferPx = minBufferPx;
60 this._maxBufferPx = maxBufferPx;
61 this._updateTotalContentSize();
62 this._updateRenderedRange();
63 }
64 /** @docs-private Implemented as part of VirtualScrollStrategy. */
65 onContentScrolled() {
66 this._updateRenderedRange();
67 }
68 /** @docs-private Implemented as part of VirtualScrollStrategy. */
69 onDataLengthChanged() {
70 this._updateTotalContentSize();
71 this._updateRenderedRange();
72 }
73 /** @docs-private Implemented as part of VirtualScrollStrategy. */
74 onContentRendered() {
75 /* no-op */
76 }
77 /** @docs-private Implemented as part of VirtualScrollStrategy. */
78 onRenderedOffsetChanged() {
79 /* no-op */
80 }
81 /**
82 * Scroll to the offset for the given index.
83 * @param index The index of the element to scroll to.
84 * @param behavior The ScrollBehavior to use when scrolling.
85 */
86 scrollToIndex(index, behavior) {
87 if (this._viewport) {
88 this._viewport.scrollToOffset(index * this._itemSize, behavior);
89 }
90 }
91 /** Update the viewport's total content size. */
92 _updateTotalContentSize() {
93 if (!this._viewport) {
94 return;
95 }
96 this._viewport.setTotalContentSize(this._viewport.getDataLength() * this._itemSize);
97 }
98 /** Update the viewport's rendered range. */
99 _updateRenderedRange() {
100 if (!this._viewport) {
101 return;
102 }
103 const renderedRange = this._viewport.getRenderedRange();
104 const newRange = { start: renderedRange.start, end: renderedRange.end };
105 const viewportSize = this._viewport.getViewportSize();
106 const dataLength = this._viewport.getDataLength();
107 let scrollOffset = this._viewport.measureScrollOffset();
108 // Prevent NaN as result when dividing by zero.
109 let firstVisibleIndex = this._itemSize > 0 ? scrollOffset / this._itemSize : 0;
110 // If user scrolls to the bottom of the list and data changes to a smaller list
111 if (newRange.end > dataLength) {
112 // We have to recalculate the first visible index based on new data length and viewport size.
113 const maxVisibleItems = Math.ceil(viewportSize / this._itemSize);
114 const newVisibleIndex = Math.max(0, Math.min(firstVisibleIndex, dataLength - maxVisibleItems));
115 // If first visible index changed we must update scroll offset to handle start/end buffers
116 // Current range must also be adjusted to cover the new position (bottom of new list).
117 if (firstVisibleIndex != newVisibleIndex) {
118 firstVisibleIndex = newVisibleIndex;
119 scrollOffset = newVisibleIndex * this._itemSize;
120 newRange.start = Math.floor(firstVisibleIndex);
121 }
122 newRange.end = Math.max(0, Math.min(dataLength, newRange.start + maxVisibleItems));
123 }
124 const startBuffer = scrollOffset - newRange.start * this._itemSize;
125 if (startBuffer < this._minBufferPx && newRange.start != 0) {
126 const expandStart = Math.ceil((this._maxBufferPx - startBuffer) / this._itemSize);
127 newRange.start = Math.max(0, newRange.start - expandStart);
128 newRange.end = Math.min(dataLength, Math.ceil(firstVisibleIndex + (viewportSize + this._minBufferPx) / this._itemSize));
129 }
130 else {
131 const endBuffer = newRange.end * this._itemSize - (scrollOffset + viewportSize);
132 if (endBuffer < this._minBufferPx && newRange.end != dataLength) {
133 const expandEnd = Math.ceil((this._maxBufferPx - endBuffer) / this._itemSize);
134 if (expandEnd > 0) {
135 newRange.end = Math.min(dataLength, newRange.end + expandEnd);
136 newRange.start = Math.max(0, Math.floor(firstVisibleIndex - this._minBufferPx / this._itemSize));
137 }
138 }
139 }
140 this._viewport.setRenderedRange(newRange);
141 this._viewport.setRenderedContentOffset(this._itemSize * newRange.start);
142 this._scrolledIndexChange.next(Math.floor(firstVisibleIndex));
143 }
144}
145/**
146 * Provider factory for `FixedSizeVirtualScrollStrategy` that simply extracts the already created
147 * `FixedSizeVirtualScrollStrategy` from the given directive.
148 * @param fixedSizeDir The instance of `CdkFixedSizeVirtualScroll` to extract the
149 * `FixedSizeVirtualScrollStrategy` from.
150 */
151function _fixedSizeVirtualScrollStrategyFactory(fixedSizeDir) {
152 return fixedSizeDir._scrollStrategy;
153}
154/** A virtual scroll strategy that supports fixed-size items. */
155class CdkFixedSizeVirtualScroll {
156 constructor() {
157 this._itemSize = 20;
158 this._minBufferPx = 100;
159 this._maxBufferPx = 200;
160 /** The scroll strategy used by this directive. */
161 this._scrollStrategy = new FixedSizeVirtualScrollStrategy(this.itemSize, this.minBufferPx, this.maxBufferPx);
162 }
163 /** The size of the items in the list (in pixels). */
164 get itemSize() {
165 return this._itemSize;
166 }
167 set itemSize(value) {
168 this._itemSize = coerceNumberProperty(value);
169 }
170 /**
171 * The minimum amount of buffer rendered beyond the viewport (in pixels).
172 * If the amount of buffer dips below this number, more items will be rendered. Defaults to 100px.
173 */
174 get minBufferPx() {
175 return this._minBufferPx;
176 }
177 set minBufferPx(value) {
178 this._minBufferPx = coerceNumberProperty(value);
179 }
180 /**
181 * The number of pixels worth of buffer to render for when rendering new items. Defaults to 200px.
182 */
183 get maxBufferPx() {
184 return this._maxBufferPx;
185 }
186 set maxBufferPx(value) {
187 this._maxBufferPx = coerceNumberProperty(value);
188 }
189 ngOnChanges() {
190 this._scrollStrategy.updateItemAndBufferSize(this.itemSize, this.minBufferPx, this.maxBufferPx);
191 }
192 static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkFixedSizeVirtualScroll, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
193 static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: CdkFixedSizeVirtualScroll, isStandalone: true, selector: "cdk-virtual-scroll-viewport[itemSize]", inputs: { itemSize: "itemSize", minBufferPx: "minBufferPx", maxBufferPx: "maxBufferPx" }, providers: [
194 {
195 provide: VIRTUAL_SCROLL_STRATEGY,
196 useFactory: _fixedSizeVirtualScrollStrategyFactory,
197 deps: [forwardRef(() => CdkFixedSizeVirtualScroll)],
198 },
199 ], usesOnChanges: true, ngImport: i0 }); }
200}
201i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkFixedSizeVirtualScroll, decorators: [{
202 type: Directive,
203 args: [{
204 selector: 'cdk-virtual-scroll-viewport[itemSize]',
205 standalone: true,
206 providers: [
207 {
208 provide: VIRTUAL_SCROLL_STRATEGY,
209 useFactory: _fixedSizeVirtualScrollStrategyFactory,
210 deps: [forwardRef(() => CdkFixedSizeVirtualScroll)],
211 },
212 ],
213 }]
214 }], propDecorators: { itemSize: [{
215 type: Input
216 }], minBufferPx: [{
217 type: Input
218 }], maxBufferPx: [{
219 type: Input
220 }] } });
221
222/** Time in ms to throttle the scrolling events by default. */
223const DEFAULT_SCROLL_TIME = 20;
224/**
225 * Service contained all registered Scrollable references and emits an event when any one of the
226 * Scrollable references emit a scrolled event.
227 */
228class ScrollDispatcher {
229 constructor(_ngZone, _platform, document) {
230 this._ngZone = _ngZone;
231 this._platform = _platform;
232 /** Subject for notifying that a registered scrollable reference element has been scrolled. */
233 this._scrolled = new Subject();
234 /** Keeps track of the global `scroll` and `resize` subscriptions. */
235 this._globalSubscription = null;
236 /** Keeps track of the amount of subscriptions to `scrolled`. Used for cleaning up afterwards. */
237 this._scrolledCount = 0;
238 /**
239 * Map of all the scrollable references that are registered with the service and their
240 * scroll event subscriptions.
241 */
242 this.scrollContainers = new Map();
243 this._document = document;
244 }
245 /**
246 * Registers a scrollable instance with the service and listens for its scrolled events. When the
247 * scrollable is scrolled, the service emits the event to its scrolled observable.
248 * @param scrollable Scrollable instance to be registered.
249 */
250 register(scrollable) {
251 if (!this.scrollContainers.has(scrollable)) {
252 this.scrollContainers.set(scrollable, scrollable.elementScrolled().subscribe(() => this._scrolled.next(scrollable)));
253 }
254 }
255 /**
256 * De-registers a Scrollable reference and unsubscribes from its scroll event observable.
257 * @param scrollable Scrollable instance to be deregistered.
258 */
259 deregister(scrollable) {
260 const scrollableReference = this.scrollContainers.get(scrollable);
261 if (scrollableReference) {
262 scrollableReference.unsubscribe();
263 this.scrollContainers.delete(scrollable);
264 }
265 }
266 /**
267 * Returns an observable that emits an event whenever any of the registered Scrollable
268 * references (or window, document, or body) fire a scrolled event. Can provide a time in ms
269 * to override the default "throttle" time.
270 *
271 * **Note:** in order to avoid hitting change detection for every scroll event,
272 * all of the events emitted from this stream will be run outside the Angular zone.
273 * If you need to update any data bindings as a result of a scroll event, you have
274 * to run the callback using `NgZone.run`.
275 */
276 scrolled(auditTimeInMs = DEFAULT_SCROLL_TIME) {
277 if (!this._platform.isBrowser) {
278 return of();
279 }
280 return new Observable((observer) => {
281 if (!this._globalSubscription) {
282 this._addGlobalListener();
283 }
284 // In the case of a 0ms delay, use an observable without auditTime
285 // since it does add a perceptible delay in processing overhead.
286 const subscription = auditTimeInMs > 0
287 ? this._scrolled.pipe(auditTime(auditTimeInMs)).subscribe(observer)
288 : this._scrolled.subscribe(observer);
289 this._scrolledCount++;
290 return () => {
291 subscription.unsubscribe();
292 this._scrolledCount--;
293 if (!this._scrolledCount) {
294 this._removeGlobalListener();
295 }
296 };
297 });
298 }
299 ngOnDestroy() {
300 this._removeGlobalListener();
301 this.scrollContainers.forEach((_, container) => this.deregister(container));
302 this._scrolled.complete();
303 }
304 /**
305 * Returns an observable that emits whenever any of the
306 * scrollable ancestors of an element are scrolled.
307 * @param elementOrElementRef Element whose ancestors to listen for.
308 * @param auditTimeInMs Time to throttle the scroll events.
309 */
310 ancestorScrolled(elementOrElementRef, auditTimeInMs) {
311 const ancestors = this.getAncestorScrollContainers(elementOrElementRef);
312 return this.scrolled(auditTimeInMs).pipe(filter(target => {
313 return !target || ancestors.indexOf(target) > -1;
314 }));
315 }
316 /** Returns all registered Scrollables that contain the provided element. */
317 getAncestorScrollContainers(elementOrElementRef) {
318 const scrollingContainers = [];
319 this.scrollContainers.forEach((_subscription, scrollable) => {
320 if (this._scrollableContainsElement(scrollable, elementOrElementRef)) {
321 scrollingContainers.push(scrollable);
322 }
323 });
324 return scrollingContainers;
325 }
326 /** Use defaultView of injected document if available or fallback to global window reference */
327 _getWindow() {
328 return this._document.defaultView || window;
329 }
330 /** Returns true if the element is contained within the provided Scrollable. */
331 _scrollableContainsElement(scrollable, elementOrElementRef) {
332 let element = coerceElement(elementOrElementRef);
333 let scrollableElement = scrollable.getElementRef().nativeElement;
334 // Traverse through the element parents until we reach null, checking if any of the elements
335 // are the scrollable's element.
336 do {
337 if (element == scrollableElement) {
338 return true;
339 }
340 } while ((element = element.parentElement));
341 return false;
342 }
343 /** Sets up the global scroll listeners. */
344 _addGlobalListener() {
345 this._globalSubscription = this._ngZone.runOutsideAngular(() => {
346 const window = this._getWindow();
347 return fromEvent(window.document, 'scroll').subscribe(() => this._scrolled.next());
348 });
349 }
350 /** Cleans up the global scroll listener. */
351 _removeGlobalListener() {
352 if (this._globalSubscription) {
353 this._globalSubscription.unsubscribe();
354 this._globalSubscription = null;
355 }
356 }
357 static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: ScrollDispatcher, deps: [{ token: i0.NgZone }, { token: i1.Platform }, { token: DOCUMENT, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
358 static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: ScrollDispatcher, providedIn: 'root' }); }
359}
360i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: ScrollDispatcher, decorators: [{
361 type: Injectable,
362 args: [{ providedIn: 'root' }]
363 }], ctorParameters: function () { return [{ type: i0.NgZone }, { type: i1.Platform }, { type: undefined, decorators: [{
364 type: Optional
365 }, {
366 type: Inject,
367 args: [DOCUMENT]
368 }] }]; } });
369
370/**
371 * Sends an event when the directive's element is scrolled. Registers itself with the
372 * ScrollDispatcher service to include itself as part of its collection of scrolling events that it
373 * can be listened to through the service.
374 */
375class CdkScrollable {
376 constructor(elementRef, scrollDispatcher, ngZone, dir) {
377 this.elementRef = elementRef;
378 this.scrollDispatcher = scrollDispatcher;
379 this.ngZone = ngZone;
380 this.dir = dir;
381 this._destroyed = new Subject();
382 this._elementScrolled = new Observable((observer) => this.ngZone.runOutsideAngular(() => fromEvent(this.elementRef.nativeElement, 'scroll')
383 .pipe(takeUntil(this._destroyed))
384 .subscribe(observer)));
385 }
386 ngOnInit() {
387 this.scrollDispatcher.register(this);
388 }
389 ngOnDestroy() {
390 this.scrollDispatcher.deregister(this);
391 this._destroyed.next();
392 this._destroyed.complete();
393 }
394 /** Returns observable that emits when a scroll event is fired on the host element. */
395 elementScrolled() {
396 return this._elementScrolled;
397 }
398 /** Gets the ElementRef for the viewport. */
399 getElementRef() {
400 return this.elementRef;
401 }
402 /**
403 * Scrolls to the specified offsets. This is a normalized version of the browser's native scrollTo
404 * method, since browsers are not consistent about what scrollLeft means in RTL. For this method
405 * left and right always refer to the left and right side of the scrolling container irrespective
406 * of the layout direction. start and end refer to left and right in an LTR context and vice-versa
407 * in an RTL context.
408 * @param options specified the offsets to scroll to.
409 */
410 scrollTo(options) {
411 const el = this.elementRef.nativeElement;
412 const isRtl = this.dir && this.dir.value == 'rtl';
413 // Rewrite start & end offsets as right or left offsets.
414 if (options.left == null) {
415 options.left = isRtl ? options.end : options.start;
416 }
417 if (options.right == null) {
418 options.right = isRtl ? options.start : options.end;
419 }
420 // Rewrite the bottom offset as a top offset.
421 if (options.bottom != null) {
422 options.top =
423 el.scrollHeight - el.clientHeight - options.bottom;
424 }
425 // Rewrite the right offset as a left offset.
426 if (isRtl && getRtlScrollAxisType() != 0 /* RtlScrollAxisType.NORMAL */) {
427 if (options.left != null) {
428 options.right =
429 el.scrollWidth - el.clientWidth - options.left;
430 }
431 if (getRtlScrollAxisType() == 2 /* RtlScrollAxisType.INVERTED */) {
432 options.left = options.right;
433 }
434 else if (getRtlScrollAxisType() == 1 /* RtlScrollAxisType.NEGATED */) {
435 options.left = options.right ? -options.right : options.right;
436 }
437 }
438 else {
439 if (options.right != null) {
440 options.left =
441 el.scrollWidth - el.clientWidth - options.right;
442 }
443 }
444 this._applyScrollToOptions(options);
445 }
446 _applyScrollToOptions(options) {
447 const el = this.elementRef.nativeElement;
448 if (supportsScrollBehavior()) {
449 el.scrollTo(options);
450 }
451 else {
452 if (options.top != null) {
453 el.scrollTop = options.top;
454 }
455 if (options.left != null) {
456 el.scrollLeft = options.left;
457 }
458 }
459 }
460 /**
461 * Measures the scroll offset relative to the specified edge of the viewport. This method can be
462 * used instead of directly checking scrollLeft or scrollTop, since browsers are not consistent
463 * about what scrollLeft means in RTL. The values returned by this method are normalized such that
464 * left and right always refer to the left and right side of the scrolling container irrespective
465 * of the layout direction. start and end refer to left and right in an LTR context and vice-versa
466 * in an RTL context.
467 * @param from The edge to measure from.
468 */
469 measureScrollOffset(from) {
470 const LEFT = 'left';
471 const RIGHT = 'right';
472 const el = this.elementRef.nativeElement;
473 if (from == 'top') {
474 return el.scrollTop;
475 }
476 if (from == 'bottom') {
477 return el.scrollHeight - el.clientHeight - el.scrollTop;
478 }
479 // Rewrite start & end as left or right offsets.
480 const isRtl = this.dir && this.dir.value == 'rtl';
481 if (from == 'start') {
482 from = isRtl ? RIGHT : LEFT;
483 }
484 else if (from == 'end') {
485 from = isRtl ? LEFT : RIGHT;
486 }
487 if (isRtl && getRtlScrollAxisType() == 2 /* RtlScrollAxisType.INVERTED */) {
488 // For INVERTED, scrollLeft is (scrollWidth - clientWidth) when scrolled all the way left and
489 // 0 when scrolled all the way right.
490 if (from == LEFT) {
491 return el.scrollWidth - el.clientWidth - el.scrollLeft;
492 }
493 else {
494 return el.scrollLeft;
495 }
496 }
497 else if (isRtl && getRtlScrollAxisType() == 1 /* RtlScrollAxisType.NEGATED */) {
498 // For NEGATED, scrollLeft is -(scrollWidth - clientWidth) when scrolled all the way left and
499 // 0 when scrolled all the way right.
500 if (from == LEFT) {
501 return el.scrollLeft + el.scrollWidth - el.clientWidth;
502 }
503 else {
504 return -el.scrollLeft;
505 }
506 }
507 else {
508 // For NORMAL, as well as non-RTL contexts, scrollLeft is 0 when scrolled all the way left and
509 // (scrollWidth - clientWidth) when scrolled all the way right.
510 if (from == LEFT) {
511 return el.scrollLeft;
512 }
513 else {
514 return el.scrollWidth - el.clientWidth - el.scrollLeft;
515 }
516 }
517 }
518 static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkScrollable, deps: [{ token: i0.ElementRef }, { token: ScrollDispatcher }, { token: i0.NgZone }, { token: i2.Directionality, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
519 static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: CdkScrollable, isStandalone: true, selector: "[cdk-scrollable], [cdkScrollable]", ngImport: i0 }); }
520}
521i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkScrollable, decorators: [{
522 type: Directive,
523 args: [{
524 selector: '[cdk-scrollable], [cdkScrollable]',
525 standalone: true,
526 }]
527 }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: ScrollDispatcher }, { type: i0.NgZone }, { type: i2.Directionality, decorators: [{
528 type: Optional
529 }] }]; } });
530
531/** Time in ms to throttle the resize events by default. */
532const DEFAULT_RESIZE_TIME = 20;
533/**
534 * Simple utility for getting the bounds of the browser viewport.
535 * @docs-private
536 */
537class ViewportRuler {
538 constructor(_platform, ngZone, document) {
539 this._platform = _platform;
540 /** Stream of viewport change events. */
541 this._change = new Subject();
542 /** Event listener that will be used to handle the viewport change events. */
543 this._changeListener = (event) => {
544 this._change.next(event);
545 };
546 this._document = document;
547 ngZone.runOutsideAngular(() => {
548 if (_platform.isBrowser) {
549 const window = this._getWindow();
550 // Note that bind the events ourselves, rather than going through something like RxJS's
551 // `fromEvent` so that we can ensure that they're bound outside of the NgZone.
552 window.addEventListener('resize', this._changeListener);
553 window.addEventListener('orientationchange', this._changeListener);
554 }
555 // Clear the cached position so that the viewport is re-measured next time it is required.
556 // We don't need to keep track of the subscription, because it is completed on destroy.
557 this.change().subscribe(() => (this._viewportSize = null));
558 });
559 }
560 ngOnDestroy() {
561 if (this._platform.isBrowser) {
562 const window = this._getWindow();
563 window.removeEventListener('resize', this._changeListener);
564 window.removeEventListener('orientationchange', this._changeListener);
565 }
566 this._change.complete();
567 }
568 /** Returns the viewport's width and height. */
569 getViewportSize() {
570 if (!this._viewportSize) {
571 this._updateViewportSize();
572 }
573 const output = { width: this._viewportSize.width, height: this._viewportSize.height };
574 // If we're not on a browser, don't cache the size since it'll be mocked out anyway.
575 if (!this._platform.isBrowser) {
576 this._viewportSize = null;
577 }
578 return output;
579 }
580 /** Gets a ClientRect for the viewport's bounds. */
581 getViewportRect() {
582 // Use the document element's bounding rect rather than the window scroll properties
583 // (e.g. pageYOffset, scrollY) due to in issue in Chrome and IE where window scroll
584 // properties and client coordinates (boundingClientRect, clientX/Y, etc.) are in different
585 // conceptual viewports. Under most circumstances these viewports are equivalent, but they
586 // can disagree when the page is pinch-zoomed (on devices that support touch).
587 // See https://bugs.chromium.org/p/chromium/issues/detail?id=489206#c4
588 // We use the documentElement instead of the body because, by default (without a css reset)
589 // browsers typically give the document body an 8px margin, which is not included in
590 // getBoundingClientRect().
591 const scrollPosition = this.getViewportScrollPosition();
592 const { width, height } = this.getViewportSize();
593 return {
594 top: scrollPosition.top,
595 left: scrollPosition.left,
596 bottom: scrollPosition.top + height,
597 right: scrollPosition.left + width,
598 height,
599 width,
600 };
601 }
602 /** Gets the (top, left) scroll position of the viewport. */
603 getViewportScrollPosition() {
604 // While we can get a reference to the fake document
605 // during SSR, it doesn't have getBoundingClientRect.
606 if (!this._platform.isBrowser) {
607 return { top: 0, left: 0 };
608 }
609 // The top-left-corner of the viewport is determined by the scroll position of the document
610 // body, normally just (scrollLeft, scrollTop). However, Chrome and Firefox disagree about
611 // whether `document.body` or `document.documentElement` is the scrolled element, so reading
612 // `scrollTop` and `scrollLeft` is inconsistent. However, using the bounding rect of
613 // `document.documentElement` works consistently, where the `top` and `left` values will
614 // equal negative the scroll position.
615 const document = this._document;
616 const window = this._getWindow();
617 const documentElement = document.documentElement;
618 const documentRect = documentElement.getBoundingClientRect();
619 const top = -documentRect.top ||
620 document.body.scrollTop ||
621 window.scrollY ||
622 documentElement.scrollTop ||
623 0;
624 const left = -documentRect.left ||
625 document.body.scrollLeft ||
626 window.scrollX ||
627 documentElement.scrollLeft ||
628 0;
629 return { top, left };
630 }
631 /**
632 * Returns a stream that emits whenever the size of the viewport changes.
633 * This stream emits outside of the Angular zone.
634 * @param throttleTime Time in milliseconds to throttle the stream.
635 */
636 change(throttleTime = DEFAULT_RESIZE_TIME) {
637 return throttleTime > 0 ? this._change.pipe(auditTime(throttleTime)) : this._change;
638 }
639 /** Use defaultView of injected document if available or fallback to global window reference */
640 _getWindow() {
641 return this._document.defaultView || window;
642 }
643 /** Updates the cached viewport size. */
644 _updateViewportSize() {
645 const window = this._getWindow();
646 this._viewportSize = this._platform.isBrowser
647 ? { width: window.innerWidth, height: window.innerHeight }
648 : { width: 0, height: 0 };
649 }
650 static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: ViewportRuler, deps: [{ token: i1.Platform }, { token: i0.NgZone }, { token: DOCUMENT, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
651 static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: ViewportRuler, providedIn: 'root' }); }
652}
653i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: ViewportRuler, decorators: [{
654 type: Injectable,
655 args: [{ providedIn: 'root' }]
656 }], ctorParameters: function () { return [{ type: i1.Platform }, { type: i0.NgZone }, { type: undefined, decorators: [{
657 type: Optional
658 }, {
659 type: Inject,
660 args: [DOCUMENT]
661 }] }]; } });
662
663const VIRTUAL_SCROLLABLE = new InjectionToken('VIRTUAL_SCROLLABLE');
664/**
665 * Extending the {@link CdkScrollable} to be used as scrolling container for virtual scrolling.
666 */
667class CdkVirtualScrollable extends CdkScrollable {
668 constructor(elementRef, scrollDispatcher, ngZone, dir) {
669 super(elementRef, scrollDispatcher, ngZone, dir);
670 }
671 /**
672 * Measure the viewport size for the provided orientation.
673 *
674 * @param orientation The orientation to measure the size from.
675 */
676 measureViewportSize(orientation) {
677 const viewportEl = this.elementRef.nativeElement;
678 return orientation === 'horizontal' ? viewportEl.clientWidth : viewportEl.clientHeight;
679 }
680 static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkVirtualScrollable, deps: [{ token: i0.ElementRef }, { token: ScrollDispatcher }, { token: i0.NgZone }, { token: i2.Directionality, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
681 static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: CdkVirtualScrollable, usesInheritance: true, ngImport: i0 }); }
682}
683i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkVirtualScrollable, decorators: [{
684 type: Directive
685 }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: ScrollDispatcher }, { type: i0.NgZone }, { type: i2.Directionality, decorators: [{
686 type: Optional
687 }] }]; } });
688
689/** Checks if the given ranges are equal. */
690function rangesEqual(r1, r2) {
691 return r1.start == r2.start && r1.end == r2.end;
692}
693/**
694 * Scheduler to be used for scroll events. Needs to fall back to
695 * something that doesn't rely on requestAnimationFrame on environments
696 * that don't support it (e.g. server-side rendering).
697 */
698const SCROLL_SCHEDULER = typeof requestAnimationFrame !== 'undefined' ? animationFrameScheduler : asapScheduler;
699/** A viewport that virtualizes its scrolling with the help of `CdkVirtualForOf`. */
700class CdkVirtualScrollViewport extends CdkVirtualScrollable {
701 /** The direction the viewport scrolls. */
702 get orientation() {
703 return this._orientation;
704 }
705 set orientation(orientation) {
706 if (this._orientation !== orientation) {
707 this._orientation = orientation;
708 this._calculateSpacerSize();
709 }
710 }
711 /**
712 * Whether rendered items should persist in the DOM after scrolling out of view. By default, items
713 * will be removed.
714 */
715 get appendOnly() {
716 return this._appendOnly;
717 }
718 set appendOnly(value) {
719 this._appendOnly = coerceBooleanProperty(value);
720 }
721 constructor(elementRef, _changeDetectorRef, ngZone, _scrollStrategy, dir, scrollDispatcher, viewportRuler, scrollable) {
722 super(elementRef, scrollDispatcher, ngZone, dir);
723 this.elementRef = elementRef;
724 this._changeDetectorRef = _changeDetectorRef;
725 this._scrollStrategy = _scrollStrategy;
726 this.scrollable = scrollable;
727 this._platform = inject(Platform);
728 /** Emits when the viewport is detached from a CdkVirtualForOf. */
729 this._detachedSubject = new Subject();
730 /** Emits when the rendered range changes. */
731 this._renderedRangeSubject = new Subject();
732 this._orientation = 'vertical';
733 this._appendOnly = false;
734 // Note: we don't use the typical EventEmitter here because we need to subscribe to the scroll
735 // strategy lazily (i.e. only if the user is actually listening to the events). We do this because
736 // depending on how the strategy calculates the scrolled index, it may come at a cost to
737 // performance.
738 /** Emits when the index of the first element visible in the viewport changes. */
739 this.scrolledIndexChange = new Observable((observer) => this._scrollStrategy.scrolledIndexChange.subscribe(index => Promise.resolve().then(() => this.ngZone.run(() => observer.next(index)))));
740 /** A stream that emits whenever the rendered range changes. */
741 this.renderedRangeStream = this._renderedRangeSubject;
742 /**
743 * The total size of all content (in pixels), including content that is not currently rendered.
744 */
745 this._totalContentSize = 0;
746 /** A string representing the `style.width` property value to be used for the spacer element. */
747 this._totalContentWidth = '';
748 /** A string representing the `style.height` property value to be used for the spacer element. */
749 this._totalContentHeight = '';
750 /** The currently rendered range of indices. */
751 this._renderedRange = { start: 0, end: 0 };
752 /** The length of the data bound to this viewport (in number of items). */
753 this._dataLength = 0;
754 /** The size of the viewport (in pixels). */
755 this._viewportSize = 0;
756 /** The last rendered content offset that was set. */
757 this._renderedContentOffset = 0;
758 /**
759 * Whether the last rendered content offset was to the end of the content (and therefore needs to
760 * be rewritten as an offset to the start of the content).
761 */
762 this._renderedContentOffsetNeedsRewrite = false;
763 /** Whether there is a pending change detection cycle. */
764 this._isChangeDetectionPending = false;
765 /** A list of functions to run after the next change detection cycle. */
766 this._runAfterChangeDetection = [];
767 /** Subscription to changes in the viewport size. */
768 this._viewportChanges = Subscription.EMPTY;
769 if (!_scrollStrategy && (typeof ngDevMode === 'undefined' || ngDevMode)) {
770 throw Error('Error: cdk-virtual-scroll-viewport requires the "itemSize" property to be set.');
771 }
772 this._viewportChanges = viewportRuler.change().subscribe(() => {
773 this.checkViewportSize();
774 });
775 if (!this.scrollable) {
776 // No scrollable is provided, so the virtual-scroll-viewport needs to become a scrollable
777 this.elementRef.nativeElement.classList.add('cdk-virtual-scrollable');
778 this.scrollable = this;
779 }
780 }
781 ngOnInit() {
782 // Scrolling depends on the element dimensions which we can't get during SSR.
783 if (!this._platform.isBrowser) {
784 return;
785 }
786 if (this.scrollable === this) {
787 super.ngOnInit();
788 }
789 // It's still too early to measure the viewport at this point. Deferring with a promise allows
790 // the Viewport to be rendered with the correct size before we measure. We run this outside the
791 // zone to avoid causing more change detection cycles. We handle the change detection loop
792 // ourselves instead.
793 this.ngZone.runOutsideAngular(() => Promise.resolve().then(() => {
794 this._measureViewportSize();
795 this._scrollStrategy.attach(this);
796 this.scrollable
797 .elementScrolled()
798 .pipe(
799 // Start off with a fake scroll event so we properly detect our initial position.
800 startWith(null),
801 // Collect multiple events into one until the next animation frame. This way if
802 // there are multiple scroll events in the same frame we only need to recheck
803 // our layout once.
804 auditTime(0, SCROLL_SCHEDULER))
805 .subscribe(() => this._scrollStrategy.onContentScrolled());
806 this._markChangeDetectionNeeded();
807 }));
808 }
809 ngOnDestroy() {
810 this.detach();
811 this._scrollStrategy.detach();
812 // Complete all subjects
813 this._renderedRangeSubject.complete();
814 this._detachedSubject.complete();
815 this._viewportChanges.unsubscribe();
816 super.ngOnDestroy();
817 }
818 /** Attaches a `CdkVirtualScrollRepeater` to this viewport. */
819 attach(forOf) {
820 if (this._forOf && (typeof ngDevMode === 'undefined' || ngDevMode)) {
821 throw Error('CdkVirtualScrollViewport is already attached.');
822 }
823 // Subscribe to the data stream of the CdkVirtualForOf to keep track of when the data length
824 // changes. Run outside the zone to avoid triggering change detection, since we're managing the
825 // change detection loop ourselves.
826 this.ngZone.runOutsideAngular(() => {
827 this._forOf = forOf;
828 this._forOf.dataStream.pipe(takeUntil(this._detachedSubject)).subscribe(data => {
829 const newLength = data.length;
830 if (newLength !== this._dataLength) {
831 this._dataLength = newLength;
832 this._scrollStrategy.onDataLengthChanged();
833 }
834 this._doChangeDetection();
835 });
836 });
837 }
838 /** Detaches the current `CdkVirtualForOf`. */
839 detach() {
840 this._forOf = null;
841 this._detachedSubject.next();
842 }
843 /** Gets the length of the data bound to this viewport (in number of items). */
844 getDataLength() {
845 return this._dataLength;
846 }
847 /** Gets the size of the viewport (in pixels). */
848 getViewportSize() {
849 return this._viewportSize;
850 }
851 // TODO(mmalerba): This is technically out of sync with what's really rendered until a render
852 // cycle happens. I'm being careful to only call it after the render cycle is complete and before
853 // setting it to something else, but its error prone and should probably be split into
854 // `pendingRange` and `renderedRange`, the latter reflecting whats actually in the DOM.
855 /** Get the current rendered range of items. */
856 getRenderedRange() {
857 return this._renderedRange;
858 }
859 measureBoundingClientRectWithScrollOffset(from) {
860 return this.getElementRef().nativeElement.getBoundingClientRect()[from];
861 }
862 /**
863 * Sets the total size of all content (in pixels), including content that is not currently
864 * rendered.
865 */
866 setTotalContentSize(size) {
867 if (this._totalContentSize !== size) {
868 this._totalContentSize = size;
869 this._calculateSpacerSize();
870 this._markChangeDetectionNeeded();
871 }
872 }
873 /** Sets the currently rendered range of indices. */
874 setRenderedRange(range) {
875 if (!rangesEqual(this._renderedRange, range)) {
876 if (this.appendOnly) {
877 range = { start: 0, end: Math.max(this._renderedRange.end, range.end) };
878 }
879 this._renderedRangeSubject.next((this._renderedRange = range));
880 this._markChangeDetectionNeeded(() => this._scrollStrategy.onContentRendered());
881 }
882 }
883 /**
884 * Gets the offset from the start of the viewport to the start of the rendered data (in pixels).
885 */
886 getOffsetToRenderedContentStart() {
887 return this._renderedContentOffsetNeedsRewrite ? null : this._renderedContentOffset;
888 }
889 /**
890 * Sets the offset from the start of the viewport to either the start or end of the rendered data
891 * (in pixels).
892 */
893 setRenderedContentOffset(offset, to = 'to-start') {
894 // In appendOnly, we always start from the top
895 offset = this.appendOnly && to === 'to-start' ? 0 : offset;
896 // For a horizontal viewport in a right-to-left language we need to translate along the x-axis
897 // in the negative direction.
898 const isRtl = this.dir && this.dir.value == 'rtl';
899 const isHorizontal = this.orientation == 'horizontal';
900 const axis = isHorizontal ? 'X' : 'Y';
901 const axisDirection = isHorizontal && isRtl ? -1 : 1;
902 let transform = `translate${axis}(${Number(axisDirection * offset)}px)`;
903 this._renderedContentOffset = offset;
904 if (to === 'to-end') {
905 transform += ` translate${axis}(-100%)`;
906 // The viewport should rewrite this as a `to-start` offset on the next render cycle. Otherwise
907 // elements will appear to expand in the wrong direction (e.g. `mat-expansion-panel` would
908 // expand upward).
909 this._renderedContentOffsetNeedsRewrite = true;
910 }
911 if (this._renderedContentTransform != transform) {
912 // We know this value is safe because we parse `offset` with `Number()` before passing it
913 // into the string.
914 this._renderedContentTransform = transform;
915 this._markChangeDetectionNeeded(() => {
916 if (this._renderedContentOffsetNeedsRewrite) {
917 this._renderedContentOffset -= this.measureRenderedContentSize();
918 this._renderedContentOffsetNeedsRewrite = false;
919 this.setRenderedContentOffset(this._renderedContentOffset);
920 }
921 else {
922 this._scrollStrategy.onRenderedOffsetChanged();
923 }
924 });
925 }
926 }
927 /**
928 * Scrolls to the given offset from the start of the viewport. Please note that this is not always
929 * the same as setting `scrollTop` or `scrollLeft`. In a horizontal viewport with right-to-left
930 * direction, this would be the equivalent of setting a fictional `scrollRight` property.
931 * @param offset The offset to scroll to.
932 * @param behavior The ScrollBehavior to use when scrolling. Default is behavior is `auto`.
933 */
934 scrollToOffset(offset, behavior = 'auto') {
935 const options = { behavior };
936 if (this.orientation === 'horizontal') {
937 options.start = offset;
938 }
939 else {
940 options.top = offset;
941 }
942 this.scrollable.scrollTo(options);
943 }
944 /**
945 * Scrolls to the offset for the given index.
946 * @param index The index of the element to scroll to.
947 * @param behavior The ScrollBehavior to use when scrolling. Default is behavior is `auto`.
948 */
949 scrollToIndex(index, behavior = 'auto') {
950 this._scrollStrategy.scrollToIndex(index, behavior);
951 }
952 /**
953 * Gets the current scroll offset from the start of the scrollable (in pixels).
954 * @param from The edge to measure the offset from. Defaults to 'top' in vertical mode and 'start'
955 * in horizontal mode.
956 */
957 measureScrollOffset(from) {
958 // This is to break the call cycle
959 let measureScrollOffset;
960 if (this.scrollable == this) {
961 measureScrollOffset = (_from) => super.measureScrollOffset(_from);
962 }
963 else {
964 measureScrollOffset = (_from) => this.scrollable.measureScrollOffset(_from);
965 }
966 return Math.max(0, measureScrollOffset(from ?? (this.orientation === 'horizontal' ? 'start' : 'top')) -
967 this.measureViewportOffset());
968 }
969 /**
970 * Measures the offset of the viewport from the scrolling container
971 * @param from The edge to measure from.
972 */
973 measureViewportOffset(from) {
974 let fromRect;
975 const LEFT = 'left';
976 const RIGHT = 'right';
977 const isRtl = this.dir?.value == 'rtl';
978 if (from == 'start') {
979 fromRect = isRtl ? RIGHT : LEFT;
980 }
981 else if (from == 'end') {
982 fromRect = isRtl ? LEFT : RIGHT;
983 }
984 else if (from) {
985 fromRect = from;
986 }
987 else {
988 fromRect = this.orientation === 'horizontal' ? 'left' : 'top';
989 }
990 const scrollerClientRect = this.scrollable.measureBoundingClientRectWithScrollOffset(fromRect);
991 const viewportClientRect = this.elementRef.nativeElement.getBoundingClientRect()[fromRect];
992 return viewportClientRect - scrollerClientRect;
993 }
994 /** Measure the combined size of all of the rendered items. */
995 measureRenderedContentSize() {
996 const contentEl = this._contentWrapper.nativeElement;
997 return this.orientation === 'horizontal' ? contentEl.offsetWidth : contentEl.offsetHeight;
998 }
999 /**
1000 * Measure the total combined size of the given range. Throws if the range includes items that are
1001 * not rendered.
1002 */
1003 measureRangeSize(range) {
1004 if (!this._forOf) {
1005 return 0;
1006 }
1007 return this._forOf.measureRangeSize(range, this.orientation);
1008 }
1009 /** Update the viewport dimensions and re-render. */
1010 checkViewportSize() {
1011 // TODO: Cleanup later when add logic for handling content resize
1012 this._measureViewportSize();
1013 this._scrollStrategy.onDataLengthChanged();
1014 }
1015 /** Measure the viewport size. */
1016 _measureViewportSize() {
1017 this._viewportSize = this.scrollable.measureViewportSize(this.orientation);
1018 }
1019 /** Queue up change detection to run. */
1020 _markChangeDetectionNeeded(runAfter) {
1021 if (runAfter) {
1022 this._runAfterChangeDetection.push(runAfter);
1023 }
1024 // Use a Promise to batch together calls to `_doChangeDetection`. This way if we set a bunch of
1025 // properties sequentially we only have to run `_doChangeDetection` once at the end.
1026 if (!this._isChangeDetectionPending) {
1027 this._isChangeDetectionPending = true;
1028 this.ngZone.runOutsideAngular(() => Promise.resolve().then(() => {
1029 this._doChangeDetection();
1030 }));
1031 }
1032 }
1033 /** Run change detection. */
1034 _doChangeDetection() {
1035 this._isChangeDetectionPending = false;
1036 // Apply the content transform. The transform can't be set via an Angular binding because
1037 // bypassSecurityTrustStyle is banned in Google. However the value is safe, it's composed of
1038 // string literals, a variable that can only be 'X' or 'Y', and user input that is run through
1039 // the `Number` function first to coerce it to a numeric value.
1040 this._contentWrapper.nativeElement.style.transform = this._renderedContentTransform;
1041 // Apply changes to Angular bindings. Note: We must call `markForCheck` to run change detection
1042 // from the root, since the repeated items are content projected in. Calling `detectChanges`
1043 // instead does not properly check the projected content.
1044 this.ngZone.run(() => this._changeDetectorRef.markForCheck());
1045 const runAfterChangeDetection = this._runAfterChangeDetection;
1046 this._runAfterChangeDetection = [];
1047 for (const fn of runAfterChangeDetection) {
1048 fn();
1049 }
1050 }
1051 /** Calculates the `style.width` and `style.height` for the spacer element. */
1052 _calculateSpacerSize() {
1053 this._totalContentHeight =
1054 this.orientation === 'horizontal' ? '' : `${this._totalContentSize}px`;
1055 this._totalContentWidth =
1056 this.orientation === 'horizontal' ? `${this._totalContentSize}px` : '';
1057 }
1058 static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkVirtualScrollViewport, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: i0.NgZone }, { token: VIRTUAL_SCROLL_STRATEGY, optional: true }, { token: i2.Directionality, optional: true }, { token: ScrollDispatcher }, { token: ViewportRuler }, { token: VIRTUAL_SCROLLABLE, optional: true }], target: i0.ɵɵFactoryTarget.Component }); }
1059 static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.0.0", type: CdkVirtualScrollViewport, isStandalone: true, selector: "cdk-virtual-scroll-viewport", inputs: { orientation: "orientation", appendOnly: "appendOnly" }, outputs: { scrolledIndexChange: "scrolledIndexChange" }, host: { properties: { "class.cdk-virtual-scroll-orientation-horizontal": "orientation === \"horizontal\"", "class.cdk-virtual-scroll-orientation-vertical": "orientation !== \"horizontal\"" }, classAttribute: "cdk-virtual-scroll-viewport" }, providers: [
1060 {
1061 provide: CdkScrollable,
1062 useFactory: (virtualScrollable, viewport) => virtualScrollable || viewport,
1063 deps: [[new Optional(), new Inject(VIRTUAL_SCROLLABLE)], CdkVirtualScrollViewport],
1064 },
1065 ], viewQueries: [{ propertyName: "_contentWrapper", first: true, predicate: ["contentWrapper"], descendants: true, static: true }], usesInheritance: true, ngImport: i0, template: "<!--\n Wrap the rendered content in an element that will be used to offset it based on the scroll\n position.\n-->\n<div #contentWrapper class=\"cdk-virtual-scroll-content-wrapper\">\n <ng-content></ng-content>\n</div>\n<!--\n Spacer used to force the scrolling container to the correct size for the *total* number of items\n so that the scrollbar captures the size of the entire data set.\n-->\n<div class=\"cdk-virtual-scroll-spacer\"\n [style.width]=\"_totalContentWidth\" [style.height]=\"_totalContentHeight\"></div>\n", styles: ["cdk-virtual-scroll-viewport{display:block;position:relative;transform:translateZ(0)}.cdk-virtual-scrollable{overflow:auto;will-change:scroll-position;contain:strict;-webkit-overflow-scrolling:touch}.cdk-virtual-scroll-content-wrapper{position:absolute;top:0;left:0;contain:content}[dir=rtl] .cdk-virtual-scroll-content-wrapper{right:0;left:auto}.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper{min-height:100%}.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>dl:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>ol:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>table:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>ul:not([cdkVirtualFor]){padding-left:0;padding-right:0;margin-left:0;margin-right:0;border-left-width:0;border-right-width:0;outline:none}.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper{min-width:100%}.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>dl:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>ol:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>table:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>ul:not([cdkVirtualFor]){padding-top:0;padding-bottom:0;margin-top:0;margin-bottom:0;border-top-width:0;border-bottom-width:0;outline:none}.cdk-virtual-scroll-spacer{height:1px;transform-origin:0 0;flex:0 0 auto}[dir=rtl] .cdk-virtual-scroll-spacer{transform-origin:100% 0}"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
1066}
1067i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkVirtualScrollViewport, decorators: [{
1068 type: Component,
1069 args: [{ selector: 'cdk-virtual-scroll-viewport', host: {
1070 'class': 'cdk-virtual-scroll-viewport',
1071 '[class.cdk-virtual-scroll-orientation-horizontal]': 'orientation === "horizontal"',
1072 '[class.cdk-virtual-scroll-orientation-vertical]': 'orientation !== "horizontal"',
1073 }, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, providers: [
1074 {
1075 provide: CdkScrollable,
1076 useFactory: (virtualScrollable, viewport) => virtualScrollable || viewport,
1077 deps: [[new Optional(), new Inject(VIRTUAL_SCROLLABLE)], CdkVirtualScrollViewport],
1078 },
1079 ], template: "<!--\n Wrap the rendered content in an element that will be used to offset it based on the scroll\n position.\n-->\n<div #contentWrapper class=\"cdk-virtual-scroll-content-wrapper\">\n <ng-content></ng-content>\n</div>\n<!--\n Spacer used to force the scrolling container to the correct size for the *total* number of items\n so that the scrollbar captures the size of the entire data set.\n-->\n<div class=\"cdk-virtual-scroll-spacer\"\n [style.width]=\"_totalContentWidth\" [style.height]=\"_totalContentHeight\"></div>\n", styles: ["cdk-virtual-scroll-viewport{display:block;position:relative;transform:translateZ(0)}.cdk-virtual-scrollable{overflow:auto;will-change:scroll-position;contain:strict;-webkit-overflow-scrolling:touch}.cdk-virtual-scroll-content-wrapper{position:absolute;top:0;left:0;contain:content}[dir=rtl] .cdk-virtual-scroll-content-wrapper{right:0;left:auto}.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper{min-height:100%}.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>dl:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>ol:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>table:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>ul:not([cdkVirtualFor]){padding-left:0;padding-right:0;margin-left:0;margin-right:0;border-left-width:0;border-right-width:0;outline:none}.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper{min-width:100%}.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>dl:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>ol:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>table:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>ul:not([cdkVirtualFor]){padding-top:0;padding-bottom:0;margin-top:0;margin-bottom:0;border-top-width:0;border-bottom-width:0;outline:none}.cdk-virtual-scroll-spacer{height:1px;transform-origin:0 0;flex:0 0 auto}[dir=rtl] .cdk-virtual-scroll-spacer{transform-origin:100% 0}"] }]
1080 }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i0.NgZone }, { type: undefined, decorators: [{
1081 type: Optional
1082 }, {
1083 type: Inject,
1084 args: [VIRTUAL_SCROLL_STRATEGY]
1085 }] }, { type: i2.Directionality, decorators: [{
1086 type: Optional
1087 }] }, { type: ScrollDispatcher }, { type: ViewportRuler }, { type: CdkVirtualScrollable, decorators: [{
1088 type: Optional
1089 }, {
1090 type: Inject,
1091 args: [VIRTUAL_SCROLLABLE]
1092 }] }]; }, propDecorators: { orientation: [{
1093 type: Input
1094 }], appendOnly: [{
1095 type: Input
1096 }], scrolledIndexChange: [{
1097 type: Output
1098 }], _contentWrapper: [{
1099 type: ViewChild,
1100 args: ['contentWrapper', { static: true }]
1101 }] } });
1102
1103/** Helper to extract the offset of a DOM Node in a certain direction. */
1104function getOffset(orientation, direction, node) {
1105 const el = node;
1106 if (!el.getBoundingClientRect) {
1107 return 0;
1108 }
1109 const rect = el.getBoundingClientRect();
1110 if (orientation === 'horizontal') {
1111 return direction === 'start' ? rect.left : rect.right;
1112 }
1113 return direction === 'start' ? rect.top : rect.bottom;
1114}
1115/**
1116 * A directive similar to `ngForOf` to be used for rendering data inside a virtual scrolling
1117 * container.
1118 */
1119class CdkVirtualForOf {
1120 /** The DataSource to display. */
1121 get cdkVirtualForOf() {
1122 return this._cdkVirtualForOf;
1123 }
1124 set cdkVirtualForOf(value) {
1125 this._cdkVirtualForOf = value;
1126 if (isDataSource(value)) {
1127 this._dataSourceChanges.next(value);
1128 }
1129 else {
1130 // If value is an an NgIterable, convert it to an array.
1131 this._dataSourceChanges.next(new ArrayDataSource(isObservable(value) ? value : Array.from(value || [])));
1132 }
1133 }
1134 /**
1135 * The `TrackByFunction` to use for tracking changes. The `TrackByFunction` takes the index and
1136 * the item and produces a value to be used as the item's identity when tracking changes.
1137 */
1138 get cdkVirtualForTrackBy() {
1139 return this._cdkVirtualForTrackBy;
1140 }
1141 set cdkVirtualForTrackBy(fn) {
1142 this._needsUpdate = true;
1143 this._cdkVirtualForTrackBy = fn
1144 ? (index, item) => fn(index + (this._renderedRange ? this._renderedRange.start : 0), item)
1145 : undefined;
1146 }
1147 /** The template used to stamp out new elements. */
1148 set cdkVirtualForTemplate(value) {
1149 if (value) {
1150 this._needsUpdate = true;
1151 this._template = value;
1152 }
1153 }
1154 /**
1155 * The size of the cache used to store templates that are not being used for re-use later.
1156 * Setting the cache size to `0` will disable caching. Defaults to 20 templates.
1157 */
1158 get cdkVirtualForTemplateCacheSize() {
1159 return this._viewRepeater.viewCacheSize;
1160 }
1161 set cdkVirtualForTemplateCacheSize(size) {
1162 this._viewRepeater.viewCacheSize = coerceNumberProperty(size);
1163 }
1164 constructor(
1165 /** The view container to add items to. */
1166 _viewContainerRef,
1167 /** The template to use when stamping out new items. */
1168 _template,
1169 /** The set of available differs. */
1170 _differs,
1171 /** The strategy used to render items in the virtual scroll viewport. */
1172 _viewRepeater,
1173 /** The virtual scrolling viewport that these items are being rendered in. */
1174 _viewport, ngZone) {
1175 this._viewContainerRef = _viewContainerRef;
1176 this._template = _template;
1177 this._differs = _differs;
1178 this._viewRepeater = _viewRepeater;
1179 this._viewport = _viewport;
1180 /** Emits when the rendered view of the data changes. */
1181 this.viewChange = new Subject();
1182 /** Subject that emits when a new DataSource instance is given. */
1183 this._dataSourceChanges = new Subject();
1184 /** Emits whenever the data in the current DataSource changes. */
1185 this.dataStream = this._dataSourceChanges.pipe(
1186 // Start off with null `DataSource`.
1187 startWith(null),
1188 // Bundle up the previous and current data sources so we can work with both.
1189 pairwise(),
1190 // Use `_changeDataSource` to disconnect from the previous data source and connect to the
1191 // new one, passing back a stream of data changes which we run through `switchMap` to give
1192 // us a data stream that emits the latest data from whatever the current `DataSource` is.
1193 switchMap(([prev, cur]) => this._changeDataSource(prev, cur)),
1194 // Replay the last emitted data when someone subscribes.
1195 shareReplay(1));
1196 /** The differ used to calculate changes to the data. */
1197 this._differ = null;
1198 /** Whether the rendered data should be updated during the next ngDoCheck cycle. */
1199 this._needsUpdate = false;
1200 this._destroyed = new Subject();
1201 this.dataStream.subscribe(data => {
1202 this._data = data;
1203 this._onRenderedDataChange();
1204 });
1205 this._viewport.renderedRangeStream.pipe(takeUntil(this._destroyed)).subscribe(range => {
1206 this._renderedRange = range;
1207 if (this.viewChange.observers.length) {
1208 ngZone.run(() => this.viewChange.next(this._renderedRange));
1209 }
1210 this._onRenderedDataChange();
1211 });
1212 this._viewport.attach(this);
1213 }
1214 /**
1215 * Measures the combined size (width for horizontal orientation, height for vertical) of all items
1216 * in the specified range. Throws an error if the range includes items that are not currently
1217 * rendered.
1218 */
1219 measureRangeSize(range, orientation) {
1220 if (range.start >= range.end) {
1221 return 0;
1222 }
1223 if ((range.start < this._renderedRange.start || range.end > this._renderedRange.end) &&
1224 (typeof ngDevMode === 'undefined' || ngDevMode)) {
1225 throw Error(`Error: attempted to measure an item that isn't rendered.`);
1226 }
1227 // The index into the list of rendered views for the first item in the range.
1228 const renderedStartIndex = range.start - this._renderedRange.start;
1229 // The length of the range we're measuring.
1230 const rangeLen = range.end - range.start;
1231 // Loop over all the views, find the first and land node and compute the size by subtracting
1232 // the top of the first node from the bottom of the last one.
1233 let firstNode;
1234 let lastNode;
1235 // Find the first node by starting from the beginning and going forwards.
1236 for (let i = 0; i < rangeLen; i++) {
1237 const view = this._viewContainerRef.get(i + renderedStartIndex);
1238 if (view && view.rootNodes.length) {
1239 firstNode = lastNode = view.rootNodes[0];
1240 break;
1241 }
1242 }
1243 // Find the last node by starting from the end and going backwards.
1244 for (let i = rangeLen - 1; i > -1; i--) {
1245 const view = this._viewContainerRef.get(i + renderedStartIndex);
1246 if (view && view.rootNodes.length) {
1247 lastNode = view.rootNodes[view.rootNodes.length - 1];
1248 break;
1249 }
1250 }
1251 return firstNode && lastNode
1252 ? getOffset(orientation, 'end', lastNode) - getOffset(orientation, 'start', firstNode)
1253 : 0;
1254 }
1255 ngDoCheck() {
1256 if (this._differ && this._needsUpdate) {
1257 // TODO(mmalerba): We should differentiate needs update due to scrolling and a new portion of
1258 // this list being rendered (can use simpler algorithm) vs needs update due to data actually
1259 // changing (need to do this diff).
1260 const changes = this._differ.diff(this._renderedItems);
1261 if (!changes) {
1262 this._updateContext();
1263 }
1264 else {
1265 this._applyChanges(changes);
1266 }
1267 this._needsUpdate = false;
1268 }
1269 }
1270 ngOnDestroy() {
1271 this._viewport.detach();
1272 this._dataSourceChanges.next(undefined);
1273 this._dataSourceChanges.complete();
1274 this.viewChange.complete();
1275 this._destroyed.next();
1276 this._destroyed.complete();
1277 this._viewRepeater.detach();
1278 }
1279 /** React to scroll state changes in the viewport. */
1280 _onRenderedDataChange() {
1281 if (!this._renderedRange) {
1282 return;
1283 }
1284 this._renderedItems = this._data.slice(this._renderedRange.start, this._renderedRange.end);
1285 if (!this._differ) {
1286 // Use a wrapper function for the `trackBy` so any new values are
1287 // picked up automatically without having to recreate the differ.
1288 this._differ = this._differs.find(this._renderedItems).create((index, item) => {
1289 return this.cdkVirtualForTrackBy ? this.cdkVirtualForTrackBy(index, item) : item;
1290 });
1291 }
1292 this._needsUpdate = true;
1293 }
1294 /** Swap out one `DataSource` for another. */
1295 _changeDataSource(oldDs, newDs) {
1296 if (oldDs) {
1297 oldDs.disconnect(this);
1298 }
1299 this._needsUpdate = true;
1300 return newDs ? newDs.connect(this) : of();
1301 }
1302 /** Update the `CdkVirtualForOfContext` for all views. */
1303 _updateContext() {
1304 const count = this._data.length;
1305 let i = this._viewContainerRef.length;
1306 while (i--) {
1307 const view = this._viewContainerRef.get(i);
1308 view.context.index = this._renderedRange.start + i;
1309 view.context.count = count;
1310 this._updateComputedContextProperties(view.context);
1311 view.detectChanges();
1312 }
1313 }
1314 /** Apply changes to the DOM. */
1315 _applyChanges(changes) {
1316 this._viewRepeater.applyChanges(changes, this._viewContainerRef, (record, _adjustedPreviousIndex, currentIndex) => this._getEmbeddedViewArgs(record, currentIndex), record => record.item);
1317 // Update $implicit for any items that had an identity change.
1318 changes.forEachIdentityChange((record) => {
1319 const view = this._viewContainerRef.get(record.currentIndex);
1320 view.context.$implicit = record.item;
1321 });
1322 // Update the context variables on all items.
1323 const count = this._data.length;
1324 let i = this._viewContainerRef.length;
1325 while (i--) {
1326 const view = this._viewContainerRef.get(i);
1327 view.context.index = this._renderedRange.start + i;
1328 view.context.count = count;
1329 this._updateComputedContextProperties(view.context);
1330 }
1331 }
1332 /** Update the computed properties on the `CdkVirtualForOfContext`. */
1333 _updateComputedContextProperties(context) {
1334 context.first = context.index === 0;
1335 context.last = context.index === context.count - 1;
1336 context.even = context.index % 2 === 0;
1337 context.odd = !context.even;
1338 }
1339 _getEmbeddedViewArgs(record, index) {
1340 // Note that it's important that we insert the item directly at the proper index,
1341 // rather than inserting it and the moving it in place, because if there's a directive
1342 // on the same node that injects the `ViewContainerRef`, Angular will insert another
1343 // comment node which can throw off the move when it's being repeated for all items.
1344 return {
1345 templateRef: this._template,
1346 context: {
1347 $implicit: record.item,
1348 // It's guaranteed that the iterable is not "undefined" or "null" because we only
1349 // generate views for elements if the "cdkVirtualForOf" iterable has elements.
1350 cdkVirtualForOf: this._cdkVirtualForOf,
1351 index: -1,
1352 count: -1,
1353 first: false,
1354 last: false,
1355 odd: false,
1356 even: false,
1357 },
1358 index,
1359 };
1360 }
1361 static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkVirtualForOf, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }, { token: i0.IterableDiffers }, { token: _VIEW_REPEATER_STRATEGY }, { token: CdkVirtualScrollViewport, skipSelf: true }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); }
1362 static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: CdkVirtualForOf, isStandalone: true, selector: "[cdkVirtualFor][cdkVirtualForOf]", inputs: { cdkVirtualForOf: "cdkVirtualForOf", cdkVirtualForTrackBy: "cdkVirtualForTrackBy", cdkVirtualForTemplate: "cdkVirtualForTemplate", cdkVirtualForTemplateCacheSize: "cdkVirtualForTemplateCacheSize" }, providers: [{ provide: _VIEW_REPEATER_STRATEGY, useClass: _RecycleViewRepeaterStrategy }], ngImport: i0 }); }
1363}
1364i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkVirtualForOf, decorators: [{
1365 type: Directive,
1366 args: [{
1367 selector: '[cdkVirtualFor][cdkVirtualForOf]',
1368 providers: [{ provide: _VIEW_REPEATER_STRATEGY, useClass: _RecycleViewRepeaterStrategy }],
1369 standalone: true,
1370 }]
1371 }], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }, { type: i0.IterableDiffers }, { type: i2$1._RecycleViewRepeaterStrategy, decorators: [{
1372 type: Inject,
1373 args: [_VIEW_REPEATER_STRATEGY]
1374 }] }, { type: CdkVirtualScrollViewport, decorators: [{
1375 type: SkipSelf
1376 }] }, { type: i0.NgZone }]; }, propDecorators: { cdkVirtualForOf: [{
1377 type: Input
1378 }], cdkVirtualForTrackBy: [{
1379 type: Input
1380 }], cdkVirtualForTemplate: [{
1381 type: Input
1382 }], cdkVirtualForTemplateCacheSize: [{
1383 type: Input
1384 }] } });
1385
1386/**
1387 * Provides a virtual scrollable for the element it is attached to.
1388 */
1389class CdkVirtualScrollableElement extends CdkVirtualScrollable {
1390 constructor(elementRef, scrollDispatcher, ngZone, dir) {
1391 super(elementRef, scrollDispatcher, ngZone, dir);
1392 }
1393 measureBoundingClientRectWithScrollOffset(from) {
1394 return (this.getElementRef().nativeElement.getBoundingClientRect()[from] -
1395 this.measureScrollOffset(from));
1396 }
1397 static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkVirtualScrollableElement, deps: [{ token: i0.ElementRef }, { token: ScrollDispatcher }, { token: i0.NgZone }, { token: i2.Directionality, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
1398 static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: CdkVirtualScrollableElement, isStandalone: true, selector: "[cdkVirtualScrollingElement]", host: { classAttribute: "cdk-virtual-scrollable" }, providers: [{ provide: VIRTUAL_SCROLLABLE, useExisting: CdkVirtualScrollableElement }], usesInheritance: true, ngImport: i0 }); }
1399}
1400i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkVirtualScrollableElement, decorators: [{
1401 type: Directive,
1402 args: [{
1403 selector: '[cdkVirtualScrollingElement]',
1404 providers: [{ provide: VIRTUAL_SCROLLABLE, useExisting: CdkVirtualScrollableElement }],
1405 standalone: true,
1406 host: {
1407 'class': 'cdk-virtual-scrollable',
1408 },
1409 }]
1410 }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: ScrollDispatcher }, { type: i0.NgZone }, { type: i2.Directionality, decorators: [{
1411 type: Optional
1412 }] }]; } });
1413
1414/**
1415 * Provides as virtual scrollable for the global / window scrollbar.
1416 */
1417class CdkVirtualScrollableWindow extends CdkVirtualScrollable {
1418 constructor(scrollDispatcher, ngZone, dir) {
1419 super(new ElementRef(document.documentElement), scrollDispatcher, ngZone, dir);
1420 this._elementScrolled = new Observable((observer) => this.ngZone.runOutsideAngular(() => fromEvent(document, 'scroll').pipe(takeUntil(this._destroyed)).subscribe(observer)));
1421 }
1422 measureBoundingClientRectWithScrollOffset(from) {
1423 return this.getElementRef().nativeElement.getBoundingClientRect()[from];
1424 }
1425 static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkVirtualScrollableWindow, deps: [{ token: ScrollDispatcher }, { token: i0.NgZone }, { token: i2.Directionality, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
1426 static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: CdkVirtualScrollableWindow, isStandalone: true, selector: "cdk-virtual-scroll-viewport[scrollWindow]", providers: [{ provide: VIRTUAL_SCROLLABLE, useExisting: CdkVirtualScrollableWindow }], usesInheritance: true, ngImport: i0 }); }
1427}
1428i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkVirtualScrollableWindow, decorators: [{
1429 type: Directive,
1430 args: [{
1431 selector: 'cdk-virtual-scroll-viewport[scrollWindow]',
1432 providers: [{ provide: VIRTUAL_SCROLLABLE, useExisting: CdkVirtualScrollableWindow }],
1433 standalone: true,
1434 }]
1435 }], ctorParameters: function () { return [{ type: ScrollDispatcher }, { type: i0.NgZone }, { type: i2.Directionality, decorators: [{
1436 type: Optional
1437 }] }]; } });
1438
1439class CdkScrollableModule {
1440 static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkScrollableModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
1441 static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.0", ngImport: i0, type: CdkScrollableModule, imports: [CdkScrollable], exports: [CdkScrollable] }); }
1442 static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkScrollableModule }); }
1443}
1444i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkScrollableModule, decorators: [{
1445 type: NgModule,
1446 args: [{
1447 exports: [CdkScrollable],
1448 imports: [CdkScrollable],
1449 }]
1450 }] });
1451/**
1452 * @docs-primary-export
1453 */
1454class ScrollingModule {
1455 static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: ScrollingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
1456 static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.0", ngImport: i0, type: ScrollingModule, imports: [BidiModule, CdkScrollableModule, CdkVirtualScrollViewport,
1457 CdkFixedSizeVirtualScroll,
1458 CdkVirtualForOf,
1459 CdkVirtualScrollableWindow,
1460 CdkVirtualScrollableElement], exports: [BidiModule, CdkScrollableModule, CdkFixedSizeVirtualScroll,
1461 CdkVirtualForOf,
1462 CdkVirtualScrollViewport,
1463 CdkVirtualScrollableWindow,
1464 CdkVirtualScrollableElement] }); }
1465 static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: ScrollingModule, imports: [BidiModule,
1466 CdkScrollableModule, BidiModule, CdkScrollableModule] }); }
1467}
1468i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: ScrollingModule, decorators: [{
1469 type: NgModule,
1470 args: [{
1471 imports: [
1472 BidiModule,
1473 CdkScrollableModule,
1474 CdkVirtualScrollViewport,
1475 CdkFixedSizeVirtualScroll,
1476 CdkVirtualForOf,
1477 CdkVirtualScrollableWindow,
1478 CdkVirtualScrollableElement,
1479 ],
1480 exports: [
1481 BidiModule,
1482 CdkScrollableModule,
1483 CdkFixedSizeVirtualScroll,
1484 CdkVirtualForOf,
1485 CdkVirtualScrollViewport,
1486 CdkVirtualScrollableWindow,
1487 CdkVirtualScrollableElement,
1488 ],
1489 }]
1490 }] });
1491
1492/**
1493 * Generated bundle index. Do not edit.
1494 */
1495
1496export { CdkFixedSizeVirtualScroll, CdkScrollable, CdkScrollableModule, CdkVirtualForOf, CdkVirtualScrollViewport, CdkVirtualScrollable, CdkVirtualScrollableElement, CdkVirtualScrollableWindow, DEFAULT_RESIZE_TIME, DEFAULT_SCROLL_TIME, FixedSizeVirtualScrollStrategy, ScrollDispatcher, ScrollingModule, VIRTUAL_SCROLLABLE, VIRTUAL_SCROLL_STRATEGY, ViewportRuler, _fixedSizeVirtualScrollStrategyFactory };
1497//# sourceMappingURL=scrolling.mjs.map