@angular/cdk 10.1.1 → 10.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/a11y/index.metadata.json +1 -1
- package/a11y/key-manager/list-key-manager.d.ts +4 -3
- package/bundles/cdk-a11y.umd.js +440 -384
- package/bundles/cdk-a11y.umd.js.map +1 -1
- package/bundles/cdk-a11y.umd.min.js +34 -10
- package/bundles/cdk-a11y.umd.min.js.map +1 -1
- package/bundles/cdk-accordion.umd.js +40 -40
- package/bundles/cdk-accordion.umd.js.map +1 -1
- package/bundles/cdk-accordion.umd.min.js +10 -2
- package/bundles/cdk-accordion.umd.min.js.map +1 -1
- package/bundles/cdk-bidi.umd.js +25 -25
- package/bundles/cdk-bidi.umd.js.map +1 -1
- package/bundles/cdk-bidi.umd.min.js +5 -4
- package/bundles/cdk-bidi.umd.min.js.map +1 -1
- package/bundles/cdk-clipboard.umd.js +37 -36
- package/bundles/cdk-clipboard.umd.js.map +1 -1
- package/bundles/cdk-clipboard.umd.min.js +10 -2
- package/bundles/cdk-clipboard.umd.min.js.map +1 -1
- package/bundles/cdk-coercion.umd.js.map +1 -1
- package/bundles/cdk-collections.umd.js +498 -238
- package/bundles/cdk-collections.umd.js.map +1 -1
- package/bundles/cdk-collections.umd.min.js +6 -4
- package/bundles/cdk-collections.umd.min.js.map +1 -1
- package/bundles/cdk-drag-drop.umd.js +508 -448
- package/bundles/cdk-drag-drop.umd.js.map +1 -1
- package/bundles/cdk-drag-drop.umd.min.js +64 -8
- package/bundles/cdk-drag-drop.umd.min.js.map +1 -1
- package/bundles/cdk-keycodes.umd.js.map +1 -1
- package/bundles/cdk-layout.umd.js +30 -26
- package/bundles/cdk-layout.umd.js.map +1 -1
- package/bundles/cdk-layout.umd.min.js +7 -6
- package/bundles/cdk-layout.umd.min.js.map +1 -1
- package/bundles/cdk-observers.umd.js +34 -34
- package/bundles/cdk-observers.umd.js.map +1 -1
- package/bundles/cdk-observers.umd.min.js +2 -2
- package/bundles/cdk-observers.umd.min.js.map +1 -1
- package/bundles/cdk-overlay.umd.js +492 -435
- package/bundles/cdk-overlay.umd.js.map +1 -1
- package/bundles/cdk-overlay.umd.min.js +51 -11
- package/bundles/cdk-overlay.umd.min.js.map +1 -1
- package/bundles/cdk-platform.umd.js +38 -11
- package/bundles/cdk-platform.umd.js.map +1 -1
- package/bundles/cdk-platform.umd.min.js +5 -12
- package/bundles/cdk-platform.umd.min.js.map +1 -1
- package/bundles/cdk-portal.umd.js +385 -322
- package/bundles/cdk-portal.umd.js.map +1 -1
- package/bundles/cdk-portal.umd.min.js +3 -12
- package/bundles/cdk-portal.umd.min.js.map +1 -1
- package/bundles/cdk-scrolling.umd.js +503 -490
- package/bundles/cdk-scrolling.umd.js.map +1 -1
- package/bundles/cdk-scrolling.umd.min.js +20 -34
- package/bundles/cdk-scrolling.umd.min.js.map +1 -1
- package/bundles/cdk-stepper.umd.js +135 -136
- package/bundles/cdk-stepper.umd.js.map +1 -1
- package/bundles/cdk-stepper.umd.min.js +11 -2
- package/bundles/cdk-stepper.umd.min.js.map +1 -1
- package/bundles/cdk-table.umd.js +923 -653
- package/bundles/cdk-table.umd.js.map +1 -1
- package/bundles/cdk-table.umd.min.js +7 -22
- package/bundles/cdk-table.umd.min.js.map +1 -1
- package/bundles/cdk-testing-protractor.umd.js +310 -245
- package/bundles/cdk-testing-protractor.umd.js.map +1 -1
- package/bundles/cdk-testing-protractor.umd.min.js +2 -9
- package/bundles/cdk-testing-protractor.umd.min.js.map +1 -1
- package/bundles/cdk-testing-testbed.umd.js +341 -292
- package/bundles/cdk-testing-testbed.umd.js.map +1 -1
- package/bundles/cdk-testing-testbed.umd.min.js +6 -29
- package/bundles/cdk-testing-testbed.umd.min.js.map +1 -1
- package/bundles/cdk-testing.umd.js +342 -270
- package/bundles/cdk-testing.umd.js.map +1 -1
- package/bundles/cdk-testing.umd.min.js +3 -17
- package/bundles/cdk-testing.umd.min.js.map +1 -1
- package/bundles/cdk-text-field.umd.js +53 -53
- package/bundles/cdk-text-field.umd.js.map +1 -1
- package/bundles/cdk-text-field.umd.min.js +10 -2
- package/bundles/cdk-text-field.umd.min.js.map +1 -1
- package/bundles/cdk-tree.umd.js +481 -417
- package/bundles/cdk-tree.umd.js.map +1 -1
- package/bundles/cdk-tree.umd.min.js +28 -3
- package/bundles/cdk-tree.umd.min.js.map +1 -1
- package/bundles/cdk.umd.js +1 -1
- package/bundles/cdk.umd.js.map +1 -1
- package/bundles/cdk.umd.min.js +1 -1
- package/bundles/cdk.umd.min.js.map +1 -1
- package/collections/dispose-view-repeater-strategy.d.ts +22 -0
- package/collections/index.metadata.json +1 -1
- package/collections/public-api.d.ts +3 -0
- package/collections/recycle-view-repeater-strategy.d.ts +56 -0
- package/collections/view-repeater.d.ts +94 -0
- package/drag-drop/index.d.ts +1 -2
- package/drag-drop/index.metadata.json +1 -1
- package/drag-drop/public-api.d.ts +2 -1
- package/esm2015/a11y/aria-describer/aria-describer.js +3 -3
- package/esm2015/a11y/focus-monitor/focus-monitor.js +3 -3
- package/esm2015/a11y/focus-trap/focus-trap.js +5 -4
- package/esm2015/a11y/key-manager/list-key-manager.js +8 -6
- package/esm2015/clipboard/pending-copy.js +7 -6
- package/esm2015/collections/collection-viewer.js +1 -0
- package/esm2015/collections/dispose-view-repeater-strategy.js +48 -0
- package/esm2015/collections/public-api.js +4 -1
- package/esm2015/collections/recycle-view-repeater-strategy.js +128 -0
- package/esm2015/collections/selection-model.js +2 -2
- package/esm2015/collections/tree-adapter.js +1 -0
- package/esm2015/collections/view-repeater.js +16 -0
- package/esm2015/drag-drop/clone-node.js +9 -1
- package/esm2015/drag-drop/directives/drag-handle.js +1 -3
- package/esm2015/drag-drop/directives/drag.js +7 -5
- package/esm2015/drag-drop/directives/drop-list.js +3 -3
- package/esm2015/drag-drop/drag-events.js +1 -0
- package/esm2015/drag-drop/drag-ref.js +2 -2
- package/esm2015/drag-drop/index.js +1 -3
- package/esm2015/drag-drop/public-api.js +3 -2
- package/esm2015/layout/breakpoints-observer.js +9 -9
- package/esm2015/overlay/dispatchers/overlay-outside-click-dispatcher.js +11 -9
- package/esm2015/overlay/overlay-config.js +1 -5
- package/esm2015/overlay/overlay-directives.js +18 -2
- package/esm2015/overlay/overlay-ref.js +6 -8
- package/esm2015/overlay/overlay-reference.js +1 -0
- package/esm2015/overlay/overlay.js +4 -4
- package/esm2015/overlay/position/connected-position-strategy.js +2 -9
- package/esm2015/overlay/position/flexible-connected-position-strategy.js +19 -16
- package/esm2015/overlay/position/position-strategy.js +1 -0
- package/esm2015/overlay/scroll/close-scroll-strategy.js +2 -2
- package/esm2015/overlay/scroll/reposition-scroll-strategy.js +2 -2
- package/esm2015/platform/features/scrolling.js +29 -2
- package/esm2015/portal/dom-portal-outlet.js +7 -4
- package/esm2015/portal/portal-directives.js +3 -3
- package/esm2015/portal/portal-injector.js +3 -1
- package/esm2015/portal/portal.js +25 -19
- package/esm2015/scrolling/fixed-size-virtual-scroll.js +2 -2
- package/esm2015/scrolling/scrolling-module.js +4 -1
- package/esm2015/scrolling/virtual-for-of.js +67 -92
- package/esm2015/scrolling/virtual-scroll-repeater.js +1 -0
- package/esm2015/scrolling/virtual-scroll-viewport.js +5 -5
- package/esm2015/stepper/stepper.js +19 -17
- package/esm2015/table/cell.js +34 -14
- package/esm2015/table/coalesced-style-scheduler.js +87 -0
- package/esm2015/table/public-api.js +2 -1
- package/esm2015/table/sticky-styler.js +79 -45
- package/esm2015/table/table-module.js +4 -2
- package/esm2015/table/table.js +70 -44
- package/esm2015/table/text-column.js +9 -5
- package/esm2015/testing/element-dimensions.js +1 -0
- package/esm2015/testing/protractor/protractor-element.js +6 -3
- package/esm2015/testing/public-api.js +2 -1
- package/esm2015/testing/test-element.js +1 -1
- package/esm2015/testing/testbed/task-state-zone-interceptor.js +2 -2
- package/esm2015/testing/testbed/unit-test-element.js +26 -21
- package/esm2015/testing/text-filtering.js +23 -0
- package/esm2015/text-field/autofill.js +3 -3
- package/esm2015/tree/control/tree-control.js +1 -0
- package/esm2015/tree/nested-node.js +2 -2
- package/esm2015/tree/padding.js +34 -20
- package/esm2015/tree/tree.js +14 -27
- package/esm2015/version.js +1 -1
- package/fesm2015/a11y.js +15 -12
- package/fesm2015/a11y.js.map +1 -1
- package/fesm2015/cdk.js +1 -1
- package/fesm2015/cdk.js.map +1 -1
- package/fesm2015/clipboard.js +6 -5
- package/fesm2015/clipboard.js.map +1 -1
- package/fesm2015/collections.js +194 -3
- package/fesm2015/collections.js.map +1 -1
- package/fesm2015/drag-drop.js +32 -23
- package/fesm2015/drag-drop.js.map +1 -1
- package/fesm2015/layout.js +8 -8
- package/fesm2015/layout.js.map +1 -1
- package/fesm2015/overlay.js +55 -48
- package/fesm2015/overlay.js.map +1 -1
- package/fesm2015/platform.js +28 -1
- package/fesm2015/platform.js.map +1 -1
- package/fesm2015/portal.js +34 -23
- package/fesm2015/portal.js.map +1 -1
- package/fesm2015/scrolling.js +72 -95
- package/fesm2015/scrolling.js.map +1 -1
- package/fesm2015/stepper.js +19 -17
- package/fesm2015/stepper.js.map +1 -1
- package/fesm2015/table.js +274 -105
- package/fesm2015/table.js.map +1 -1
- package/fesm2015/testing/protractor.js +5 -2
- package/fesm2015/testing/protractor.js.map +1 -1
- package/fesm2015/testing/testbed.js +26 -21
- package/fesm2015/testing/testbed.js.map +1 -1
- package/fesm2015/testing.js +24 -1
- package/fesm2015/testing.js.map +1 -1
- package/fesm2015/text-field.js +2 -2
- package/fesm2015/text-field.js.map +1 -1
- package/fesm2015/tree.js +46 -45
- package/fesm2015/tree.js.map +1 -1
- package/layout/breakpoints-observer.d.ts +3 -3
- package/overlay/index.metadata.json +1 -1
- package/overlay/overlay-config.d.ts +0 -4
- package/overlay/overlay-directives.d.ts +1 -0
- package/overlay/position/connected-position-strategy.d.ts +1 -3
- package/package.json +1 -1
- package/platform/index.metadata.json +1 -1
- package/portal/index.metadata.json +1 -1
- package/portal/portal-injector.d.ts +2 -0
- package/schematics/index.js +1 -1
- package/schematics/ng-add/index.js +1 -1
- package/schematics/ng-update/data/index.js +1 -1
- package/schematics/ng-update/public-api.js +1 -1
- package/schematics/update-tool/public-api.js +1 -1
- package/schematics/utils/index.js +1 -1
- package/scrolling/index.metadata.json +1 -1
- package/scrolling/scrolling-module.d.ts +3 -0
- package/scrolling/virtual-for-of.d.ts +11 -19
- package/stepper/index.metadata.json +1 -1
- package/stepper/stepper.d.ts +7 -10
- package/table/cell.d.ts +21 -1
- package/table/coalesced-style-scheduler.d.ts +41 -0
- package/table/index.metadata.json +1 -1
- package/table/public-api.d.ts +1 -0
- package/table/sticky-styler.d.ts +7 -1
- package/table/table.d.ts +14 -8
- package/testing/protractor/protractor-element.d.ts +2 -2
- package/testing/public-api.d.ts +1 -0
- package/testing/test-element.d.ts +9 -2
- package/testing/testbed/unit-test-element.d.ts +9 -2
- package/testing/text-filtering.d.ts +13 -0
- package/tree/index.metadata.json +1 -1
- package/tree/padding.d.ts +14 -0
- package/tree/tree.d.ts +2 -4
package/fesm2015/scrolling.js
CHANGED
|
@@ -5,7 +5,7 @@ import { distinctUntilChanged, auditTime, filter, takeUntil, startWith, pairwise
|
|
|
5
5
|
import { Platform, getRtlScrollAxisType, supportsScrollBehavior, PlatformModule } from '@angular/cdk/platform';
|
|
6
6
|
import { DOCUMENT } from '@angular/common';
|
|
7
7
|
import { Directionality, BidiModule } from '@angular/cdk/bidi';
|
|
8
|
-
import { isDataSource, ArrayDataSource } from '@angular/cdk/collections';
|
|
8
|
+
import { isDataSource, ArrayDataSource, _VIEW_REPEATER_STRATEGY, _RecycleViewRepeaterStrategy } from '@angular/cdk/collections';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* @license
|
|
@@ -62,7 +62,7 @@ class FixedSizeVirtualScrollStrategy {
|
|
|
62
62
|
* @param maxBufferPx The amount of buffer (in pixels) to render when rendering more.
|
|
63
63
|
*/
|
|
64
64
|
updateItemAndBufferSize(itemSize, minBufferPx, maxBufferPx) {
|
|
65
|
-
if (maxBufferPx < minBufferPx) {
|
|
65
|
+
if (maxBufferPx < minBufferPx && (typeof ngDevMode === 'undefined' || ngDevMode)) {
|
|
66
66
|
throw Error('CDK virtual scroll: maxBufferPx must be greater than or equal to minBufferPx');
|
|
67
67
|
}
|
|
68
68
|
this._itemSize = itemSize;
|
|
@@ -705,7 +705,7 @@ class CdkVirtualScrollViewport extends CdkScrollable {
|
|
|
705
705
|
/** Emits when the index of the first element visible in the viewport changes. */
|
|
706
706
|
this.scrolledIndexChange = new Observable((observer) => this._scrollStrategy.scrolledIndexChange.subscribe(index => Promise.resolve().then(() => this.ngZone.run(() => observer.next(index)))));
|
|
707
707
|
/** A stream that emits whenever the rendered range changes. */
|
|
708
|
-
this.renderedRangeStream = this._renderedRangeSubject
|
|
708
|
+
this.renderedRangeStream = this._renderedRangeSubject;
|
|
709
709
|
/**
|
|
710
710
|
* The total size of all content (in pixels), including content that is not currently rendered.
|
|
711
711
|
*/
|
|
@@ -733,7 +733,7 @@ class CdkVirtualScrollViewport extends CdkScrollable {
|
|
|
733
733
|
this._runAfterChangeDetection = [];
|
|
734
734
|
/** Subscription to changes in the viewport size. */
|
|
735
735
|
this._viewportChanges = Subscription.EMPTY;
|
|
736
|
-
if (!_scrollStrategy) {
|
|
736
|
+
if (!_scrollStrategy && (typeof ngDevMode === 'undefined' || ngDevMode)) {
|
|
737
737
|
throw Error('Error: cdk-virtual-scroll-viewport requires the "itemSize" property to be set.');
|
|
738
738
|
}
|
|
739
739
|
// @breaking-change 11.0.0 Remove null check for `viewportRuler`.
|
|
@@ -785,7 +785,7 @@ class CdkVirtualScrollViewport extends CdkScrollable {
|
|
|
785
785
|
}
|
|
786
786
|
/** Attaches a `CdkVirtualScrollRepeater` to this viewport. */
|
|
787
787
|
attach(forOf) {
|
|
788
|
-
if (this._forOf) {
|
|
788
|
+
if (this._forOf && (typeof ngDevMode === 'undefined' || ngDevMode)) {
|
|
789
789
|
throw Error('CdkVirtualScrollViewport is already attached.');
|
|
790
790
|
}
|
|
791
791
|
// Subscribe to the data stream of the CdkVirtualForOf to keep track of when the data length
|
|
@@ -1011,7 +1011,7 @@ CdkVirtualScrollViewport.ctorParameters = () => [
|
|
|
1011
1011
|
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [VIRTUAL_SCROLL_STRATEGY,] }] },
|
|
1012
1012
|
{ type: Directionality, decorators: [{ type: Optional }] },
|
|
1013
1013
|
{ type: ScrollDispatcher },
|
|
1014
|
-
{ type: ViewportRuler
|
|
1014
|
+
{ type: ViewportRuler }
|
|
1015
1015
|
];
|
|
1016
1016
|
CdkVirtualScrollViewport.propDecorators = {
|
|
1017
1017
|
orientation: [{ type: Input }],
|
|
@@ -1026,14 +1026,17 @@ CdkVirtualScrollViewport.propDecorators = {
|
|
|
1026
1026
|
* Use of this source code is governed by an MIT-style license that can be
|
|
1027
1027
|
* found in the LICENSE file at https://angular.io/license
|
|
1028
1028
|
*/
|
|
1029
|
-
/** Helper to extract
|
|
1030
|
-
function
|
|
1029
|
+
/** Helper to extract the offset of a DOM Node in a certain direction. */
|
|
1030
|
+
function getOffset(orientation, direction, node) {
|
|
1031
1031
|
const el = node;
|
|
1032
1032
|
if (!el.getBoundingClientRect) {
|
|
1033
1033
|
return 0;
|
|
1034
1034
|
}
|
|
1035
1035
|
const rect = el.getBoundingClientRect();
|
|
1036
|
-
|
|
1036
|
+
if (orientation === 'horizontal') {
|
|
1037
|
+
return direction === 'start' ? rect.left : rect.right;
|
|
1038
|
+
}
|
|
1039
|
+
return direction === 'start' ? rect.top : rect.bottom;
|
|
1037
1040
|
}
|
|
1038
1041
|
/**
|
|
1039
1042
|
* A directive similar to `ngForOf` to be used for rendering data inside a virtual scrolling
|
|
@@ -1047,21 +1050,19 @@ class CdkVirtualForOf {
|
|
|
1047
1050
|
_template,
|
|
1048
1051
|
/** The set of available differs. */
|
|
1049
1052
|
_differs,
|
|
1053
|
+
/** The strategy used to render items in the virtual scroll viewport. */
|
|
1054
|
+
_viewRepeater,
|
|
1050
1055
|
/** The virtual scrolling viewport that these items are being rendered in. */
|
|
1051
1056
|
_viewport, ngZone) {
|
|
1052
1057
|
this._viewContainerRef = _viewContainerRef;
|
|
1053
1058
|
this._template = _template;
|
|
1054
1059
|
this._differs = _differs;
|
|
1060
|
+
this._viewRepeater = _viewRepeater;
|
|
1055
1061
|
this._viewport = _viewport;
|
|
1056
1062
|
/** Emits when the rendered view of the data changes. */
|
|
1057
1063
|
this.viewChange = new Subject();
|
|
1058
1064
|
/** Subject that emits when a new DataSource instance is given. */
|
|
1059
1065
|
this._dataSourceChanges = new Subject();
|
|
1060
|
-
/**
|
|
1061
|
-
* The size of the cache used to store templates that are not being used for re-use later.
|
|
1062
|
-
* Setting the cache size to `0` will disable caching. Defaults to 20 templates.
|
|
1063
|
-
*/
|
|
1064
|
-
this.cdkVirtualForTemplateCacheSize = 20;
|
|
1065
1066
|
/** Emits whenever the data in the current DataSource changes. */
|
|
1066
1067
|
this.dataStream = this._dataSourceChanges
|
|
1067
1068
|
.pipe(
|
|
@@ -1077,12 +1078,6 @@ class CdkVirtualForOf {
|
|
|
1077
1078
|
shareReplay(1));
|
|
1078
1079
|
/** The differ used to calculate changes to the data. */
|
|
1079
1080
|
this._differ = null;
|
|
1080
|
-
/**
|
|
1081
|
-
* The template cache used to hold on ot template instancess that have been stamped out, but don't
|
|
1082
|
-
* currently need to be rendered. These instances will be reused in the future rather than
|
|
1083
|
-
* stamping out brand new ones.
|
|
1084
|
-
*/
|
|
1085
|
-
this._templateCache = [];
|
|
1086
1081
|
/** Whether the rendered data should be updated during the next ngDoCheck cycle. */
|
|
1087
1082
|
this._needsUpdate = false;
|
|
1088
1083
|
this._destroyed = new Subject();
|
|
@@ -1131,6 +1126,16 @@ class CdkVirtualForOf {
|
|
|
1131
1126
|
this._template = value;
|
|
1132
1127
|
}
|
|
1133
1128
|
}
|
|
1129
|
+
/**
|
|
1130
|
+
* The size of the cache used to store templates that are not being used for re-use later.
|
|
1131
|
+
* Setting the cache size to `0` will disable caching. Defaults to 20 templates.
|
|
1132
|
+
*/
|
|
1133
|
+
get cdkVirtualForTemplateCacheSize() {
|
|
1134
|
+
return this._viewRepeater.viewCacheSize;
|
|
1135
|
+
}
|
|
1136
|
+
set cdkVirtualForTemplateCacheSize(size) {
|
|
1137
|
+
this._viewRepeater.viewCacheSize = coerceNumberProperty(size);
|
|
1138
|
+
}
|
|
1134
1139
|
/**
|
|
1135
1140
|
* Measures the combined size (width for horizontal orientation, height for vertical) of all items
|
|
1136
1141
|
* in the specified range. Throws an error if the range includes items that are not currently
|
|
@@ -1140,24 +1145,36 @@ class CdkVirtualForOf {
|
|
|
1140
1145
|
if (range.start >= range.end) {
|
|
1141
1146
|
return 0;
|
|
1142
1147
|
}
|
|
1143
|
-
if (range.start < this._renderedRange.start || range.end > this._renderedRange.end)
|
|
1148
|
+
if ((range.start < this._renderedRange.start || range.end > this._renderedRange.end) &&
|
|
1149
|
+
(typeof ngDevMode === 'undefined' || ngDevMode)) {
|
|
1144
1150
|
throw Error(`Error: attempted to measure an item that isn't rendered.`);
|
|
1145
1151
|
}
|
|
1146
1152
|
// The index into the list of rendered views for the first item in the range.
|
|
1147
1153
|
const renderedStartIndex = range.start - this._renderedRange.start;
|
|
1148
1154
|
// The length of the range we're measuring.
|
|
1149
1155
|
const rangeLen = range.end - range.start;
|
|
1150
|
-
// Loop over all
|
|
1151
|
-
|
|
1152
|
-
let
|
|
1153
|
-
|
|
1156
|
+
// Loop over all the views, find the first and land node and compute the size by subtracting
|
|
1157
|
+
// the top of the first node from the bottom of the last one.
|
|
1158
|
+
let firstNode;
|
|
1159
|
+
let lastNode;
|
|
1160
|
+
// Find the first node by starting from the beginning and going forwards.
|
|
1161
|
+
for (let i = 0; i < rangeLen; i++) {
|
|
1162
|
+
const view = this._viewContainerRef.get(i + renderedStartIndex);
|
|
1163
|
+
if (view && view.rootNodes.length) {
|
|
1164
|
+
firstNode = lastNode = view.rootNodes[0];
|
|
1165
|
+
break;
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
// Find the last node by starting from the end and going backwards.
|
|
1169
|
+
for (let i = rangeLen - 1; i > -1; i--) {
|
|
1154
1170
|
const view = this._viewContainerRef.get(i + renderedStartIndex);
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1171
|
+
if (view && view.rootNodes.length) {
|
|
1172
|
+
lastNode = view.rootNodes[view.rootNodes.length - 1];
|
|
1173
|
+
break;
|
|
1158
1174
|
}
|
|
1159
1175
|
}
|
|
1160
|
-
return
|
|
1176
|
+
return firstNode && lastNode ?
|
|
1177
|
+
getOffset(orientation, 'end', lastNode) - getOffset(orientation, 'start', firstNode) : 0;
|
|
1161
1178
|
}
|
|
1162
1179
|
ngDoCheck() {
|
|
1163
1180
|
if (this._differ && this._needsUpdate) {
|
|
@@ -1181,9 +1198,7 @@ class CdkVirtualForOf {
|
|
|
1181
1198
|
this.viewChange.complete();
|
|
1182
1199
|
this._destroyed.next();
|
|
1183
1200
|
this._destroyed.complete();
|
|
1184
|
-
|
|
1185
|
-
view.destroy();
|
|
1186
|
-
}
|
|
1201
|
+
this._viewRepeater.detach();
|
|
1187
1202
|
}
|
|
1188
1203
|
/** React to scroll state changes in the viewport. */
|
|
1189
1204
|
_onRenderedDataChange() {
|
|
@@ -1218,21 +1233,7 @@ class CdkVirtualForOf {
|
|
|
1218
1233
|
}
|
|
1219
1234
|
/** Apply changes to the DOM. */
|
|
1220
1235
|
_applyChanges(changes) {
|
|
1221
|
-
|
|
1222
|
-
changes.forEachOperation((record, adjustedPreviousIndex, currentIndex) => {
|
|
1223
|
-
if (record.previousIndex == null) { // Item added.
|
|
1224
|
-
const view = this._insertViewForNewItem(currentIndex);
|
|
1225
|
-
view.context.$implicit = record.item;
|
|
1226
|
-
}
|
|
1227
|
-
else if (currentIndex == null) { // Item removed.
|
|
1228
|
-
this._cacheView(this._detachView(adjustedPreviousIndex));
|
|
1229
|
-
}
|
|
1230
|
-
else { // Item moved.
|
|
1231
|
-
const view = this._viewContainerRef.get(adjustedPreviousIndex);
|
|
1232
|
-
this._viewContainerRef.move(view, currentIndex);
|
|
1233
|
-
view.context.$implicit = record.item;
|
|
1234
|
-
}
|
|
1235
|
-
});
|
|
1236
|
+
this._viewRepeater.applyChanges(changes, this._viewContainerRef, (record, adjustedPreviousIndex, currentIndex) => this._getEmbeddedViewArgs(record, currentIndex), (record) => record.item);
|
|
1236
1237
|
// Update $implicit for any items that had an identity change.
|
|
1237
1238
|
changes.forEachIdentityChange((record) => {
|
|
1238
1239
|
const view = this._viewContainerRef.get(record.currentIndex);
|
|
@@ -1248,28 +1249,6 @@ class CdkVirtualForOf {
|
|
|
1248
1249
|
this._updateComputedContextProperties(view.context);
|
|
1249
1250
|
}
|
|
1250
1251
|
}
|
|
1251
|
-
/** Cache the given detached view. */
|
|
1252
|
-
_cacheView(view) {
|
|
1253
|
-
if (this._templateCache.length < this.cdkVirtualForTemplateCacheSize) {
|
|
1254
|
-
this._templateCache.push(view);
|
|
1255
|
-
}
|
|
1256
|
-
else {
|
|
1257
|
-
const index = this._viewContainerRef.indexOf(view);
|
|
1258
|
-
// It's very unlikely that the index will ever be -1, but just in case,
|
|
1259
|
-
// destroy the view on its own, otherwise destroy it through the
|
|
1260
|
-
// container to ensure that all the references are removed.
|
|
1261
|
-
if (index === -1) {
|
|
1262
|
-
view.destroy();
|
|
1263
|
-
}
|
|
1264
|
-
else {
|
|
1265
|
-
this._viewContainerRef.remove(index);
|
|
1266
|
-
}
|
|
1267
|
-
}
|
|
1268
|
-
}
|
|
1269
|
-
/** Inserts a view for a new item, either from the cache or by creating a new one. */
|
|
1270
|
-
_insertViewForNewItem(index) {
|
|
1271
|
-
return this._insertViewFromCache(index) || this._createEmbeddedViewAt(index);
|
|
1272
|
-
}
|
|
1273
1252
|
/** Update the computed properties on the `CdkVirtualForOfContext`. */
|
|
1274
1253
|
_updateComputedContextProperties(context) {
|
|
1275
1254
|
context.first = context.index === 0;
|
|
@@ -1277,47 +1256,42 @@ class CdkVirtualForOf {
|
|
|
1277
1256
|
context.even = context.index % 2 === 0;
|
|
1278
1257
|
context.odd = !context.even;
|
|
1279
1258
|
}
|
|
1280
|
-
|
|
1281
|
-
_createEmbeddedViewAt(index) {
|
|
1259
|
+
_getEmbeddedViewArgs(record, index) {
|
|
1282
1260
|
// Note that it's important that we insert the item directly at the proper index,
|
|
1283
1261
|
// rather than inserting it and the moving it in place, because if there's a directive
|
|
1284
1262
|
// on the same node that injects the `ViewContainerRef`, Angular will insert another
|
|
1285
1263
|
// comment node which can throw off the move when it's being repeated for all items.
|
|
1286
|
-
return
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
if (cachedView) {
|
|
1303
|
-
this._viewContainerRef.insert(cachedView, index);
|
|
1304
|
-
}
|
|
1305
|
-
return cachedView || null;
|
|
1306
|
-
}
|
|
1307
|
-
/** Detaches the embedded view at the given index. */
|
|
1308
|
-
_detachView(index) {
|
|
1309
|
-
return this._viewContainerRef.detach(index);
|
|
1264
|
+
return {
|
|
1265
|
+
templateRef: this._template,
|
|
1266
|
+
context: {
|
|
1267
|
+
$implicit: record.item,
|
|
1268
|
+
// It's guaranteed that the iterable is not "undefined" or "null" because we only
|
|
1269
|
+
// generate views for elements if the "cdkVirtualForOf" iterable has elements.
|
|
1270
|
+
cdkVirtualForOf: this._cdkVirtualForOf,
|
|
1271
|
+
index: -1,
|
|
1272
|
+
count: -1,
|
|
1273
|
+
first: false,
|
|
1274
|
+
last: false,
|
|
1275
|
+
odd: false,
|
|
1276
|
+
even: false
|
|
1277
|
+
},
|
|
1278
|
+
index,
|
|
1279
|
+
};
|
|
1310
1280
|
}
|
|
1311
1281
|
}
|
|
1312
1282
|
CdkVirtualForOf.decorators = [
|
|
1313
1283
|
{ type: Directive, args: [{
|
|
1314
1284
|
selector: '[cdkVirtualFor][cdkVirtualForOf]',
|
|
1285
|
+
providers: [
|
|
1286
|
+
{ provide: _VIEW_REPEATER_STRATEGY, useClass: _RecycleViewRepeaterStrategy },
|
|
1287
|
+
]
|
|
1315
1288
|
},] }
|
|
1316
1289
|
];
|
|
1317
1290
|
CdkVirtualForOf.ctorParameters = () => [
|
|
1318
1291
|
{ type: ViewContainerRef },
|
|
1319
1292
|
{ type: TemplateRef },
|
|
1320
1293
|
{ type: IterableDiffers },
|
|
1294
|
+
{ type: _RecycleViewRepeaterStrategy, decorators: [{ type: Inject, args: [_VIEW_REPEATER_STRATEGY,] }] },
|
|
1321
1295
|
{ type: CdkVirtualScrollViewport, decorators: [{ type: SkipSelf }] },
|
|
1322
1296
|
{ type: NgZone }
|
|
1323
1297
|
];
|
|
@@ -1343,6 +1317,9 @@ CdkScrollableModule.decorators = [
|
|
|
1343
1317
|
declarations: [CdkScrollable]
|
|
1344
1318
|
},] }
|
|
1345
1319
|
];
|
|
1320
|
+
/**
|
|
1321
|
+
* @docs-primary-export
|
|
1322
|
+
*/
|
|
1346
1323
|
class ScrollingModule {
|
|
1347
1324
|
}
|
|
1348
1325
|
ScrollingModule.decorators = [
|