ng-virtual-list 20.11.5 → 20.11.7
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/fesm2022/ng-virtual-list.mjs +63 -73
- package/fesm2022/ng-virtual-list.mjs.map +1 -1
- package/index.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1079,6 +1079,7 @@ class TrackBox extends CacheMap {
|
|
|
1079
1079
|
_resetBufferSizeTimer;
|
|
1080
1080
|
_isReseted = true;
|
|
1081
1081
|
_prerenderedCache = null;
|
|
1082
|
+
_newItems = [];
|
|
1082
1083
|
lifeCircle() {
|
|
1083
1084
|
this.fireChangeIfNeed();
|
|
1084
1085
|
this.fireTick();
|
|
@@ -1105,6 +1106,7 @@ class TrackBox extends CacheMap {
|
|
|
1105
1106
|
updateCache(previousCollection, currentCollection, itemSize) {
|
|
1106
1107
|
const trackBy = this._trackingPropertyName;
|
|
1107
1108
|
let crudDetected = false;
|
|
1109
|
+
this._newItems = [];
|
|
1108
1110
|
if (!currentCollection || currentCollection.length === 0) {
|
|
1109
1111
|
if (previousCollection) {
|
|
1110
1112
|
// deleted
|
|
@@ -1172,6 +1174,7 @@ class TrackBox extends CacheMap {
|
|
|
1172
1174
|
const item = currentCollection[i], id = item[trackBy];
|
|
1173
1175
|
if (item && !deletedMap.hasOwnProperty(id) && !updatedMap.hasOwnProperty(id) &&
|
|
1174
1176
|
!notChangedMap.hasOwnProperty(id)) {
|
|
1177
|
+
this._newItems.push(id);
|
|
1175
1178
|
// added
|
|
1176
1179
|
crudDetected = true;
|
|
1177
1180
|
this._map.set(id, { width: itemSize, height: itemSize, method: ItemDisplayMethods.CREATE });
|
|
@@ -1339,7 +1342,7 @@ class TrackBox extends CacheMap {
|
|
|
1339
1342
|
}
|
|
1340
1343
|
}
|
|
1341
1344
|
}
|
|
1342
|
-
let y = this._scrollStartOffset,
|
|
1345
|
+
let y = this._scrollStartOffset, stickyComponentSize = 0;
|
|
1343
1346
|
for (let i = 0, l = collection.length; i < l; i++) {
|
|
1344
1347
|
const ii = i + 1, collectionItem = collection[i], id = collectionItem[trackBy];
|
|
1345
1348
|
let componentSize = 0, componentSizeDelta = 0, itemDisplayMethod = ItemDisplayMethods.NOT_CHANGED;
|
|
@@ -1347,7 +1350,7 @@ class TrackBox extends CacheMap {
|
|
|
1347
1350
|
const cache = map.get(id);
|
|
1348
1351
|
componentSize = cache[sizeProperty] > 0 ? cache[sizeProperty] : typicalItemSize;
|
|
1349
1352
|
itemDisplayMethod = cache?.method ?? ItemDisplayMethods.UPDATE;
|
|
1350
|
-
const isItemNew =
|
|
1353
|
+
const isItemNew = this._newItems.indexOf(id) > -1 || (this._isLazy && isStart && !this._isReseted);
|
|
1351
1354
|
isNew = isItemNew;
|
|
1352
1355
|
if (isNew) {
|
|
1353
1356
|
isUpdating = true;
|
|
@@ -1385,7 +1388,6 @@ class TrackBox extends CacheMap {
|
|
|
1385
1388
|
if (itemById === undefined) {
|
|
1386
1389
|
if (id !== fromItemId && id === stickyItemId && itemConfigMap?.[id]?.sticky === 1) {
|
|
1387
1390
|
stickyComponentSize = componentSize;
|
|
1388
|
-
stickyCollectionItem = collectionItem;
|
|
1389
1391
|
y -= stickyComponentSize;
|
|
1390
1392
|
}
|
|
1391
1393
|
if (id === fromItemId) {
|
|
@@ -1529,9 +1531,6 @@ class TrackBox extends CacheMap {
|
|
|
1529
1531
|
refreshCache(cache) {
|
|
1530
1532
|
this._prerenderedCache = cache;
|
|
1531
1533
|
}
|
|
1532
|
-
clearDeltaDirection() {
|
|
1533
|
-
this.clearScrollDirectionCache();
|
|
1534
|
-
}
|
|
1535
1534
|
clearDelta(clearDirectionDetector = false) {
|
|
1536
1535
|
this._delta = this._deltaOfNewItems = 0;
|
|
1537
1536
|
if (clearDirectionDetector) {
|
|
@@ -1854,18 +1853,8 @@ class TrackBox extends CacheMap {
|
|
|
1854
1853
|
this._prerenderedCache = null;
|
|
1855
1854
|
}
|
|
1856
1855
|
}
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
if (!!cache) {
|
|
1860
|
-
for (const id in cache) {
|
|
1861
|
-
const cacheItem = cache[id];
|
|
1862
|
-
if (!!cacheItem) {
|
|
1863
|
-
const { width, height, method } = cacheItem;
|
|
1864
|
-
this.set(id, { width, height, method });
|
|
1865
|
-
}
|
|
1866
|
-
}
|
|
1867
|
-
this._prerenderedCache = null;
|
|
1868
|
-
}
|
|
1856
|
+
resetCacheChunkInfo() {
|
|
1857
|
+
this._newItems = [];
|
|
1869
1858
|
}
|
|
1870
1859
|
cacheClean() {
|
|
1871
1860
|
this._map.clear();
|
|
@@ -5749,8 +5738,8 @@ class NgVirtualListComponent {
|
|
|
5749
5738
|
$fireUpdate.pipe(takeUntilDestroyed(), tap(userAction => {
|
|
5750
5739
|
hasUserAction = userAction;
|
|
5751
5740
|
})).subscribe();
|
|
5752
|
-
let renderStabilizerPrevScrollStateVersion = EMPTY_SCROLL_STATE_VERSION, renderStabilizerUpdateIterations = 0;
|
|
5753
5741
|
const $update = this.$update, renderStabilizer = (options) => {
|
|
5742
|
+
let renderStabilizerPrevScrollStateVersion = EMPTY_SCROLL_STATE_VERSION, renderStabilizerUpdateIterations = 0;
|
|
5754
5743
|
const prepareIterations = options?.prepareIterations ?? PREPARE_ITERATIONS, prepareReupdateLength = options?.prepareReupdateLength ?? PREPARATION_REUPDATE_LENGTH;
|
|
5755
5744
|
return of(null).pipe(takeUntilDestroyed(this._destroyRef), switchMap$1(() => {
|
|
5756
5745
|
renderStabilizerPrevScrollStateVersion = EMPTY_SCROLL_STATE_VERSION;
|
|
@@ -5970,6 +5959,38 @@ class NgVirtualListComponent {
|
|
|
5970
5959
|
return of({ items, collapsedIds, itemConfigMap, trackBy });
|
|
5971
5960
|
}));
|
|
5972
5961
|
}));
|
|
5962
|
+
$itemsComposition.pipe(takeUntilDestroyed(), switchMap$1(({ items, collapsedIds, itemConfigMap, trackBy }) => {
|
|
5963
|
+
if (items.length === 0 || !this._readyForShow || !(this.cachable && !this._cached &&
|
|
5964
|
+
!this._trackBox.isSnappedToStart && this._trackBox.isSnappedToEnd)) {
|
|
5965
|
+
return of({ items, collapsedIds, itemConfigMap, trackBy });
|
|
5966
|
+
}
|
|
5967
|
+
return $updateItemsRenderStabilizer.pipe(takeUntilDestroyed(this._destroyRef), take(1), debounceTime(0), switchMap$1(() => {
|
|
5968
|
+
return of({ items, collapsedIds, itemConfigMap, trackBy });
|
|
5969
|
+
}));
|
|
5970
|
+
}), tap(({ items, collapsedIds, itemConfigMap, trackBy }) => {
|
|
5971
|
+
const hiddenItems = new CMap();
|
|
5972
|
+
let isCollapsed = false;
|
|
5973
|
+
for (let i = 0, l = items.length; i < l; i++) {
|
|
5974
|
+
const item = items[i], id = item[trackBy], group = (itemConfigMap[id]?.sticky ?? 0) > 0, collapsed = collapsedIds.includes(id);
|
|
5975
|
+
if (group) {
|
|
5976
|
+
isCollapsed = collapsed;
|
|
5977
|
+
}
|
|
5978
|
+
else {
|
|
5979
|
+
if (isCollapsed) {
|
|
5980
|
+
hiddenItems.set(id, true);
|
|
5981
|
+
}
|
|
5982
|
+
}
|
|
5983
|
+
}
|
|
5984
|
+
const actualItems = [];
|
|
5985
|
+
for (let i = 0, l = items.length; i < l; i++) {
|
|
5986
|
+
const item = items[i], id = item[trackBy];
|
|
5987
|
+
if (hiddenItems.has(id)) {
|
|
5988
|
+
continue;
|
|
5989
|
+
}
|
|
5990
|
+
actualItems.push(item);
|
|
5991
|
+
}
|
|
5992
|
+
this._actualItems.set(actualItems);
|
|
5993
|
+
})).subscribe();
|
|
5973
5994
|
$isVertical.pipe(takeUntilDestroyed(), tap(v => {
|
|
5974
5995
|
this._isVertical = v;
|
|
5975
5996
|
const el = this._elementRef.nativeElement;
|
|
@@ -6027,56 +6048,26 @@ class NgVirtualListComponent {
|
|
|
6027
6048
|
this._$fireUpdate.next(true);
|
|
6028
6049
|
}));
|
|
6029
6050
|
})).subscribe();
|
|
6030
|
-
let
|
|
6051
|
+
let isChunkLoading = false;
|
|
6031
6052
|
const $loading = toObservable(this.loading);
|
|
6032
6053
|
$loading.pipe(takeUntilDestroyed(), distinctUntilChanged(), skip(1), filter$1(v => !v), switchMap$1(() => {
|
|
6033
|
-
|
|
6054
|
+
isChunkLoading = true;
|
|
6034
6055
|
const scrollbar = this._scrollerComponent();
|
|
6035
6056
|
if (!!scrollbar) {
|
|
6036
6057
|
scrollbar.stopScrollbar();
|
|
6037
6058
|
scrollbar.refreshScrollbar();
|
|
6038
6059
|
}
|
|
6039
|
-
return $
|
|
6060
|
+
return $actualItems.pipe(takeUntilDestroyed(this._destroyRef), take(1), tap(() => {
|
|
6061
|
+
this._$fireUpdateNextFrame.next(true);
|
|
6062
|
+
}), switchMap$1(() => $chunkLoadingRenderStabilizer.pipe(takeUntilDestroyed(this._destroyRef), take(1), tap(() => {
|
|
6063
|
+
isChunkLoading = false;
|
|
6064
|
+
this._trackBox.resetCacheChunkInfo();
|
|
6040
6065
|
const scrollbar = this._scrollerComponent();
|
|
6041
6066
|
if (!!scrollbar) {
|
|
6042
6067
|
scrollbar.stopScrollbar();
|
|
6043
6068
|
scrollbar.refreshScrollbar();
|
|
6044
6069
|
}
|
|
6045
|
-
|
|
6046
|
-
this._trackBox.resetCacheFlags();
|
|
6047
|
-
}));
|
|
6048
|
-
})).subscribe();
|
|
6049
|
-
$itemsComposition.pipe(takeUntilDestroyed(), switchMap$1(({ items, collapsedIds, itemConfigMap, trackBy }) => {
|
|
6050
|
-
if (chunkLoaded || items.length === 0 || !this._readyForShow || !(this.cachable && !this._cached &&
|
|
6051
|
-
!this._trackBox.isSnappedToStart && this._trackBox.isSnappedToEnd)) {
|
|
6052
|
-
return of({ items, collapsedIds, itemConfigMap, trackBy });
|
|
6053
|
-
}
|
|
6054
|
-
return $updateItemsRenderStabilizer.pipe(takeUntilDestroyed(this._destroyRef), take(1), debounceTime(0), switchMap$1(() => {
|
|
6055
|
-
return of({ items, collapsedIds, itemConfigMap, trackBy });
|
|
6056
|
-
}));
|
|
6057
|
-
}), tap(({ items, collapsedIds, itemConfigMap, trackBy }) => {
|
|
6058
|
-
const hiddenItems = new CMap();
|
|
6059
|
-
let isCollapsed = false;
|
|
6060
|
-
for (let i = 0, l = items.length; i < l; i++) {
|
|
6061
|
-
const item = items[i], id = item[trackBy], group = (itemConfigMap[id]?.sticky ?? 0) > 0, collapsed = collapsedIds.includes(id);
|
|
6062
|
-
if (group) {
|
|
6063
|
-
isCollapsed = collapsed;
|
|
6064
|
-
}
|
|
6065
|
-
else {
|
|
6066
|
-
if (isCollapsed) {
|
|
6067
|
-
hiddenItems.set(id, true);
|
|
6068
|
-
}
|
|
6069
|
-
}
|
|
6070
|
-
}
|
|
6071
|
-
const actualItems = [];
|
|
6072
|
-
for (let i = 0, l = items.length; i < l; i++) {
|
|
6073
|
-
const item = items[i], id = item[trackBy];
|
|
6074
|
-
if (hiddenItems.has(id)) {
|
|
6075
|
-
continue;
|
|
6076
|
-
}
|
|
6077
|
-
actualItems.push(item);
|
|
6078
|
-
}
|
|
6079
|
-
this._actualItems.set(actualItems);
|
|
6070
|
+
}))));
|
|
6080
6071
|
})).subscribe();
|
|
6081
6072
|
$loading.pipe(takeUntilDestroyed(), skip(1), distinctUntilChanged(), tap(v => {
|
|
6082
6073
|
if (v) {
|
|
@@ -6094,7 +6085,7 @@ class NgVirtualListComponent {
|
|
|
6094
6085
|
const scroller = this._scrollerComponent();
|
|
6095
6086
|
let totalSize = 0;
|
|
6096
6087
|
if (scroller) {
|
|
6097
|
-
const collapsable = collapsedIds.length > 0, cachable = this.cachable, cached = this._cached, waitingCache = cachable && !cached, emitUpdate = !this._readyForShow || waitingCache || collapsable;
|
|
6088
|
+
const collapsable = collapsedIds.length > 0, cachable = this.cachable, cached = this._cached, waitingCache = cachable && !cached, emitUpdate = !this._readyForShow || waitingCache || collapsable || isChunkLoading;
|
|
6098
6089
|
if (this._readyForShow || (cachable && cached)) {
|
|
6099
6090
|
const currentScrollSize = (isVertical ? scroller.scrollTop ?? 0 : scroller.scrollLeft ?? 0), fireUpdate = emitUpdate || reupdate || (!optimization && !userAction) || this._$scrollingTo.getValue();
|
|
6100
6091
|
let actualScrollSize = !this._readyForShow && snapScrollToEnd ? (isVertical ? scroller.scrollHeight ?? 0 : scroller.scrollWidth ?? 0) :
|
|
@@ -6168,23 +6159,22 @@ class NgVirtualListComponent {
|
|
|
6168
6159
|
this._trackBox.isScrollEnd;
|
|
6169
6160
|
return;
|
|
6170
6161
|
}
|
|
6171
|
-
if (scrollPositionAfterUpdate >= 0 && scrollPositionAfterUpdate < roundedMaxPositionAfterUpdate)
|
|
6172
|
-
|
|
6173
|
-
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
|
|
6178
|
-
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
}
|
|
6162
|
+
if ((scrollPositionAfterUpdate >= 0 && scrollPositionAfterUpdate < roundedMaxPositionAfterUpdate) ||
|
|
6163
|
+
(scrollSize !== roundedMaxPositionAfterUpdate || currentScrollSize !== scrollPositionAfterUpdate)) {
|
|
6164
|
+
this._trackBox.clearDelta();
|
|
6165
|
+
if (this._readyForShow) {
|
|
6166
|
+
this.emitScrollEvent(true, false, userAction);
|
|
6167
|
+
}
|
|
6168
|
+
const params = {
|
|
6169
|
+
[isVertical ? TOP_PROP_NAME : LEFT_PROP_NAME]: scrollPositionAfterUpdate, blending: true, userAction,
|
|
6170
|
+
fireUpdate, behavior: BEHAVIOR_INSTANT, duration: this.animationParams().scrollToItem,
|
|
6171
|
+
};
|
|
6172
|
+
scroller.scrollTo(params);
|
|
6173
|
+
if (emitUpdate) {
|
|
6174
|
+
this._$update.next(this.getScrollStateVersion(totalSize, this._isVertical ? scroller.scrollTop : scroller.scrollLeft, cacheVersion));
|
|
6185
6175
|
}
|
|
6186
|
-
return;
|
|
6187
6176
|
}
|
|
6177
|
+
return;
|
|
6188
6178
|
}
|
|
6189
6179
|
if (emitUpdate) {
|
|
6190
6180
|
this._$update.next(this.getScrollStateVersion(totalSize, this._isVertical ? scroller.scrollTop : scroller.scrollLeft, cacheVersion));
|