/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import { ArrayDataSource, isDataSource, _RecycleViewRepeaterStrategy, _VIEW_REPEATER_STRATEGY, } from '@angular/cdk/collections'; import { Directive, Inject, Input, IterableDiffers, NgZone, SkipSelf, TemplateRef, ViewContainerRef, } from '@angular/core'; import { coerceNumberProperty } from '@angular/cdk/coercion'; import { Subject, of as observableOf, isObservable } from 'rxjs'; import { pairwise, shareReplay, startWith, switchMap, takeUntil } from 'rxjs/operators'; import { CdkVirtualScrollViewport } from './virtual-scroll-viewport'; /** Helper to extract the offset of a DOM Node in a certain direction. */ function getOffset(orientation, direction, node) { const el = node; if (!el.getBoundingClientRect) { return 0; } const rect = el.getBoundingClientRect(); if (orientation === 'horizontal') { return direction === 'start' ? rect.left : rect.right; } return direction === 'start' ? rect.top : rect.bottom; } /** * A directive similar to `ngForOf` to be used for rendering data inside a virtual scrolling * container. */ export class CdkVirtualForOf { constructor( /** The view container to add items to. */ _viewContainerRef, /** The template to use when stamping out new items. */ _template, /** The set of available differs. */ _differs, /** The strategy used to render items in the virtual scroll viewport. */ _viewRepeater, /** The virtual scrolling viewport that these items are being rendered in. */ _viewport, ngZone) { this._viewContainerRef = _viewContainerRef; this._template = _template; this._differs = _differs; this._viewRepeater = _viewRepeater; this._viewport = _viewport; /** Emits when the rendered view of the data changes. */ this.viewChange = new Subject(); /** Subject that emits when a new DataSource instance is given. */ this._dataSourceChanges = new Subject(); /** Emits whenever the data in the current DataSource changes. */ this.dataStream = this._dataSourceChanges .pipe( // Start off with null `DataSource`. startWith(null), // Bundle up the previous and current data sources so we can work with both. pairwise(), // Use `_changeDataSource` to disconnect from the previous data source and connect to the // new one, passing back a stream of data changes which we run through `switchMap` to give // us a data stream that emits the latest data from whatever the current `DataSource` is. switchMap(([prev, cur]) => this._changeDataSource(prev, cur)), // Replay the last emitted data when someone subscribes. shareReplay(1)); /** The differ used to calculate changes to the data. */ this._differ = null; /** Whether the rendered data should be updated during the next ngDoCheck cycle. */ this._needsUpdate = false; this._destroyed = new Subject(); this.dataStream.subscribe(data => { this._data = data; this._onRenderedDataChange(); }); this._viewport.renderedRangeStream.pipe(takeUntil(this._destroyed)).subscribe(range => { this._renderedRange = range; ngZone.run(() => this.viewChange.next(this._renderedRange)); this._onRenderedDataChange(); }); this._viewport.attach(this); } /** The DataSource to display. */ get cdkVirtualForOf() { return this._cdkVirtualForOf; } set cdkVirtualForOf(value) { this._cdkVirtualForOf = value; if (isDataSource(value)) { this._dataSourceChanges.next(value); } else { // If value is an an NgIterable, convert it to an array. this._dataSourceChanges.next(new ArrayDataSource(isObservable(value) ? value : Array.from(value || []))); } } /** * The `TrackByFunction` to use for tracking changes. The `TrackByFunction` takes the index and * the item and produces a value to be used as the item's identity when tracking changes. */ get cdkVirtualForTrackBy() { return this._cdkVirtualForTrackBy; } set cdkVirtualForTrackBy(fn) { this._needsUpdate = true; this._cdkVirtualForTrackBy = fn ? (index, item) => fn(index + (this._renderedRange ? this._renderedRange.start : 0), item) : undefined; } /** The template used to stamp out new elements. */ set cdkVirtualForTemplate(value) { if (value) { this._needsUpdate = true; this._template = value; } } /** * The size of the cache used to store templates that are not being used for re-use later. * Setting the cache size to `0` will disable caching. Defaults to 20 templates. */ get cdkVirtualForTemplateCacheSize() { return this._viewRepeater.viewCacheSize; } set cdkVirtualForTemplateCacheSize(size) { this._viewRepeater.viewCacheSize = coerceNumberProperty(size); } /** * Measures the combined size (width for horizontal orientation, height for vertical) of all items * in the specified range. Throws an error if the range includes items that are not currently * rendered. */ measureRangeSize(range, orientation) { if (range.start >= range.end) { return 0; } if ((range.start < this._renderedRange.start || range.end > this._renderedRange.end) && (typeof ngDevMode === 'undefined' || ngDevMode)) { throw Error(`Error: attempted to measure an item that isn't rendered.`); } // The index into the list of rendered views for the first item in the range. const renderedStartIndex = range.start - this._renderedRange.start; // The length of the range we're measuring. const rangeLen = range.end - range.start; // Loop over all the views, find the first and land node and compute the size by subtracting // the top of the first node from the bottom of the last one. let firstNode; let lastNode; // Find the first node by starting from the beginning and going forwards. for (let i = 0; i < rangeLen; i++) { const view = this._viewContainerRef.get(i + renderedStartIndex); if (view && view.rootNodes.length) { firstNode = lastNode = view.rootNodes[0]; break; } } // Find the last node by starting from the end and going backwards. for (let i = rangeLen - 1; i > -1; i--) { const view = this._viewContainerRef.get(i + renderedStartIndex); if (view && view.rootNodes.length) { lastNode = view.rootNodes[view.rootNodes.length - 1]; break; } } return firstNode && lastNode ? getOffset(orientation, 'end', lastNode) - getOffset(orientation, 'start', firstNode) : 0; } ngDoCheck() { if (this._differ && this._needsUpdate) { // TODO(mmalerba): We should differentiate needs update due to scrolling and a new portion of // this list being rendered (can use simpler algorithm) vs needs update due to data actually // changing (need to do this diff). const changes = this._differ.diff(this._renderedItems); if (!changes) { this._updateContext(); } else { this._applyChanges(changes); } this._needsUpdate = false; } } ngOnDestroy() { this._viewport.detach(); this._dataSourceChanges.next(undefined); this._dataSourceChanges.complete(); this.viewChange.complete(); this._destroyed.next(); this._destroyed.complete(); this._viewRepeater.detach(); } /** React to scroll state changes in the viewport. */ _onRenderedDataChange() { if (!this._renderedRange) { return; } this._renderedItems = this._data.slice(this._renderedRange.start, this._renderedRange.end); if (!this._differ) { // Use a wrapper function for the `trackBy` so any new values are // picked up automatically without having to recreate the differ. this._differ = this._differs.find(this._renderedItems).create((index, item) => { return this.cdkVirtualForTrackBy ? this.cdkVirtualForTrackBy(index, item) : item; }); } this._needsUpdate = true; } /** Swap out one `DataSource` for another. */ _changeDataSource(oldDs, newDs) { if (oldDs) { oldDs.disconnect(this); } this._needsUpdate = true; return newDs ? newDs.connect(this) : observableOf(); } /** Update the `CdkVirtualForOfContext` for all views. */ _updateContext() { const count = this._data.length; let i = this._viewContainerRef.length; while (i--) { const view = this._viewContainerRef.get(i); view.context.index = this._renderedRange.start + i; view.context.count = count; this._updateComputedContextProperties(view.context); view.detectChanges(); } } /** Apply changes to the DOM. */ _applyChanges(changes) { this._viewRepeater.applyChanges(changes, this._viewContainerRef, (record, _adjustedPreviousIndex, currentIndex) => this._getEmbeddedViewArgs(record, currentIndex), (record) => record.item); // Update $implicit for any items that had an identity change. changes.forEachIdentityChange((record) => { const view = this._viewContainerRef.get(record.currentIndex); view.context.$implicit = record.item; }); // Update the context variables on all items. const count = this._data.length; let i = this._viewContainerRef.length; while (i--) { const view = this._viewContainerRef.get(i); view.context.index = this._renderedRange.start + i; view.context.count = count; this._updateComputedContextProperties(view.context); } } /** Update the computed properties on the `CdkVirtualForOfContext`. */ _updateComputedContextProperties(context) { context.first = context.index === 0; context.last = context.index === context.count - 1; context.even = context.index % 2 === 0; context.odd = !context.even; } _getEmbeddedViewArgs(record, index) { // Note that it's important that we insert the item directly at the proper index, // rather than inserting it and the moving it in place, because if there's a directive // on the same node that injects the `ViewContainerRef`, Angular will insert another // comment node which can throw off the move when it's being repeated for all items. return { templateRef: this._template, context: { $implicit: record.item, // It's guaranteed that the iterable is not "undefined" or "null" because we only // generate views for elements if the "cdkVirtualForOf" iterable has elements. cdkVirtualForOf: this._cdkVirtualForOf, index: -1, count: -1, first: false, last: false, odd: false, even: false }, index, }; } } CdkVirtualForOf.decorators = [ { type: Directive, args: [{ selector: '[cdkVirtualFor][cdkVirtualForOf]', providers: [ { provide: _VIEW_REPEATER_STRATEGY, useClass: _RecycleViewRepeaterStrategy }, ] },] } ]; CdkVirtualForOf.ctorParameters = () => [ { type: ViewContainerRef }, { type: TemplateRef }, { type: IterableDiffers }, { type: _RecycleViewRepeaterStrategy, decorators: [{ type: Inject, args: [_VIEW_REPEATER_STRATEGY,] }] }, { type: CdkVirtualScrollViewport, decorators: [{ type: SkipSelf }] }, { type: NgZone } ]; CdkVirtualForOf.propDecorators = { cdkVirtualForOf: [{ type: Input }], cdkVirtualForTrackBy: [{ type: Input }], cdkVirtualForTemplate: [{ type: Input }], cdkVirtualForTemplateCacheSize: [{ type: Input }] }; //# sourceMappingURL=data:application/json;base64,eyJ2Z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