ng-virtual-list 20.11.5 → 20.11.6
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 +43 -52
- package/fesm2022/ng-virtual-list.mjs.map +1 -1
- package/index.d.ts +2 -1
- 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 });
|
|
@@ -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;
|
|
@@ -1356,7 +1359,7 @@ class TrackBox extends CacheMap {
|
|
|
1356
1359
|
componentSizeDelta = componentSnapshotSize;
|
|
1357
1360
|
switch (itemDisplayMethod) {
|
|
1358
1361
|
case ItemDisplayMethods.UPDATE: {
|
|
1359
|
-
map.set(id, { ...cache, method: isNew ? ItemDisplayMethods.UPDATE : ItemDisplayMethods.NOT_CHANGED
|
|
1362
|
+
map.set(id, { ...cache, method: isNew ? ItemDisplayMethods.UPDATE : ItemDisplayMethods.NOT_CHANGED });
|
|
1360
1363
|
if (isNew && y <= (scrollSize + size + deltaFromStartCreation + componentSize)) {
|
|
1361
1364
|
deltaFromStartCreation += componentSizeDelta;
|
|
1362
1365
|
componentSizeDelta = 0;
|
|
@@ -1854,18 +1857,8 @@ class TrackBox extends CacheMap {
|
|
|
1854
1857
|
this._prerenderedCache = null;
|
|
1855
1858
|
}
|
|
1856
1859
|
}
|
|
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
|
-
}
|
|
1860
|
+
resetCacheChunkInfo() {
|
|
1861
|
+
this._newItems = [];
|
|
1869
1862
|
}
|
|
1870
1863
|
cacheClean() {
|
|
1871
1864
|
this._map.clear();
|
|
@@ -5970,6 +5963,38 @@ class NgVirtualListComponent {
|
|
|
5970
5963
|
return of({ items, collapsedIds, itemConfigMap, trackBy });
|
|
5971
5964
|
}));
|
|
5972
5965
|
}));
|
|
5966
|
+
$itemsComposition.pipe(takeUntilDestroyed(), switchMap$1(({ items, collapsedIds, itemConfigMap, trackBy }) => {
|
|
5967
|
+
if (items.length === 0 || !this._readyForShow || !(this.cachable && !this._cached &&
|
|
5968
|
+
!this._trackBox.isSnappedToStart && this._trackBox.isSnappedToEnd)) {
|
|
5969
|
+
return of({ items, collapsedIds, itemConfigMap, trackBy });
|
|
5970
|
+
}
|
|
5971
|
+
return $updateItemsRenderStabilizer.pipe(takeUntilDestroyed(this._destroyRef), take(1), debounceTime(0), switchMap$1(() => {
|
|
5972
|
+
return of({ items, collapsedIds, itemConfigMap, trackBy });
|
|
5973
|
+
}));
|
|
5974
|
+
}), tap(({ items, collapsedIds, itemConfigMap, trackBy }) => {
|
|
5975
|
+
const hiddenItems = new CMap();
|
|
5976
|
+
let isCollapsed = false;
|
|
5977
|
+
for (let i = 0, l = items.length; i < l; i++) {
|
|
5978
|
+
const item = items[i], id = item[trackBy], group = (itemConfigMap[id]?.sticky ?? 0) > 0, collapsed = collapsedIds.includes(id);
|
|
5979
|
+
if (group) {
|
|
5980
|
+
isCollapsed = collapsed;
|
|
5981
|
+
}
|
|
5982
|
+
else {
|
|
5983
|
+
if (isCollapsed) {
|
|
5984
|
+
hiddenItems.set(id, true);
|
|
5985
|
+
}
|
|
5986
|
+
}
|
|
5987
|
+
}
|
|
5988
|
+
const actualItems = [];
|
|
5989
|
+
for (let i = 0, l = items.length; i < l; i++) {
|
|
5990
|
+
const item = items[i], id = item[trackBy];
|
|
5991
|
+
if (hiddenItems.has(id)) {
|
|
5992
|
+
continue;
|
|
5993
|
+
}
|
|
5994
|
+
actualItems.push(item);
|
|
5995
|
+
}
|
|
5996
|
+
this._actualItems.set(actualItems);
|
|
5997
|
+
})).subscribe();
|
|
5973
5998
|
$isVertical.pipe(takeUntilDestroyed(), tap(v => {
|
|
5974
5999
|
this._isVertical = v;
|
|
5975
6000
|
const el = this._elementRef.nativeElement;
|
|
@@ -6027,56 +6052,22 @@ class NgVirtualListComponent {
|
|
|
6027
6052
|
this._$fireUpdate.next(true);
|
|
6028
6053
|
}));
|
|
6029
6054
|
})).subscribe();
|
|
6030
|
-
let chunkLoaded = false;
|
|
6031
6055
|
const $loading = toObservable(this.loading);
|
|
6032
6056
|
$loading.pipe(takeUntilDestroyed(), distinctUntilChanged(), skip(1), filter$1(v => !v), switchMap$1(() => {
|
|
6033
|
-
chunkLoaded = true;
|
|
6034
6057
|
const scrollbar = this._scrollerComponent();
|
|
6035
6058
|
if (!!scrollbar) {
|
|
6036
6059
|
scrollbar.stopScrollbar();
|
|
6037
6060
|
scrollbar.refreshScrollbar();
|
|
6038
6061
|
}
|
|
6039
|
-
return $chunkLoadingRenderStabilizer.pipe(takeUntilDestroyed(this._destroyRef), take(1), tap(() => {
|
|
6062
|
+
return $actualItems.pipe(takeUntilDestroyed(this._destroyRef), take(1), switchMap$1(() => $chunkLoadingRenderStabilizer.pipe(takeUntilDestroyed(this._destroyRef), take(1), tap(() => {
|
|
6063
|
+
console.log('reset');
|
|
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) {
|