ng-virtual-list 20.11.4 → 20.11.5

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.
@@ -275,6 +275,7 @@ const PART_ITEM_FOCUSED = ' item-focused';
275
275
  const MIN_PIXELS_FOR_PREVENT_SNAPPING = 10;
276
276
  const MAX_VELOCITY_FOR_SCROLL_QUALITY_OPTIMIZATION_LVL1 = 74;
277
277
  const MAX_VELOCITY_FOR_SCROLL_QUALITY_OPTIMIZATION_LVL2 = 500;
278
+ const MAX_NUMBERS_OF_SKIPS_FOR_QUALITY_OPTIMIZATION_LVL1 = 4;
278
279
  const RANGE_DISPLAY_ITEMS_END_OFFSET = 20;
279
280
  const PREPARE_ITERATIONS = 1;
280
281
  const PREPARATION_REUPDATE_LENGTH = 0;
@@ -1853,6 +1854,19 @@ class TrackBox extends CacheMap {
1853
1854
  this._prerenderedCache = null;
1854
1855
  }
1855
1856
  }
1857
+ resetCacheFlags() {
1858
+ const cache = this._map.toObject();
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
+ }
1869
+ }
1856
1870
  cacheClean() {
1857
1871
  this._map.clear();
1858
1872
  this._snapshot.clear();
@@ -5769,6 +5783,9 @@ class NgVirtualListComponent {
5769
5783
  }), $updateItemsRenderStabilizer = renderStabilizer({
5770
5784
  prepareIterations: PREPARE_ITERATIONS_FOR_UPDATE_ITEMS,
5771
5785
  prepareReupdateLength: PREPARATION_REUPDATE_LENGTH_FOR_UPDATE_ITEMS,
5786
+ }), $chunkLoadingRenderStabilizer = renderStabilizer({
5787
+ prepareIterations: PREPARE_ITERATIONS_FOR_UPDATE_ITEMS,
5788
+ prepareReupdateLength: PREPARATION_REUPDATE_LENGTH_FOR_UPDATE_ITEMS,
5772
5789
  }), $collapseItemsRenderStabilizer = renderStabilizer({
5773
5790
  prepareIterations: PREPARE_ITERATIONS_FOR_COLLAPSE_ITEMS,
5774
5791
  prepareReupdateLength: PREPARATION_REUPDATE_LENGTH_FOR_COLLAPSE_ITEMS,
@@ -5953,38 +5970,6 @@ class NgVirtualListComponent {
5953
5970
  return of({ items, collapsedIds, itemConfigMap, trackBy });
5954
5971
  }));
5955
5972
  }));
5956
- $itemsComposition.pipe(takeUntilDestroyed(), switchMap$1(({ items, collapsedIds, itemConfigMap, trackBy }) => {
5957
- if (items.length === 0 || !this._readyForShow || !(this.cachable && !this._cached &&
5958
- !this._trackBox.isSnappedToStart && this._trackBox.isSnappedToEnd)) {
5959
- return of({ items, collapsedIds, itemConfigMap, trackBy });
5960
- }
5961
- return $updateItemsRenderStabilizer.pipe(takeUntilDestroyed(this._destroyRef), take(1), debounceTime(0), switchMap$1(() => {
5962
- return of({ items, collapsedIds, itemConfigMap, trackBy });
5963
- }));
5964
- }), tap(({ items, collapsedIds, itemConfigMap, trackBy }) => {
5965
- const hiddenItems = new CMap();
5966
- let isCollapsed = false;
5967
- for (let i = 0, l = items.length; i < l; i++) {
5968
- const item = items[i], id = item[trackBy], group = (itemConfigMap[id]?.sticky ?? 0) > 0, collapsed = collapsedIds.includes(id);
5969
- if (group) {
5970
- isCollapsed = collapsed;
5971
- }
5972
- else {
5973
- if (isCollapsed) {
5974
- hiddenItems.set(id, true);
5975
- }
5976
- }
5977
- }
5978
- const actualItems = [];
5979
- for (let i = 0, l = items.length; i < l; i++) {
5980
- const item = items[i], id = item[trackBy];
5981
- if (hiddenItems.has(id)) {
5982
- continue;
5983
- }
5984
- actualItems.push(item);
5985
- }
5986
- this._actualItems.set(actualItems);
5987
- })).subscribe();
5988
5973
  $isVertical.pipe(takeUntilDestroyed(), tap(v => {
5989
5974
  this._isVertical = v;
5990
5975
  const el = this._elementRef.nativeElement;
@@ -6042,11 +6027,56 @@ class NgVirtualListComponent {
6042
6027
  this._$fireUpdate.next(true);
6043
6028
  }));
6044
6029
  })).subscribe();
6030
+ let chunkLoaded = false;
6045
6031
  const $loading = toObservable(this.loading);
6046
6032
  $loading.pipe(takeUntilDestroyed(), distinctUntilChanged(), skip(1), filter$1(v => !v), switchMap$1(() => {
6047
- return $actualItems.pipe(takeUntilDestroyed(this._destroyRef), debounceTime(100), take(1), tap(() => {
6048
- this._scrollerComponent()?.refreshScrollbar();
6033
+ chunkLoaded = true;
6034
+ const scrollbar = this._scrollerComponent();
6035
+ if (!!scrollbar) {
6036
+ scrollbar.stopScrollbar();
6037
+ scrollbar.refreshScrollbar();
6038
+ }
6039
+ return $chunkLoadingRenderStabilizer.pipe(takeUntilDestroyed(this._destroyRef), take(1), tap(() => {
6040
+ const scrollbar = this._scrollerComponent();
6041
+ if (!!scrollbar) {
6042
+ scrollbar.stopScrollbar();
6043
+ scrollbar.refreshScrollbar();
6044
+ }
6045
+ chunkLoaded = false;
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 });
6049
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);
6050
6080
  })).subscribe();
6051
6081
  $loading.pipe(takeUntilDestroyed(), skip(1), distinctUntilChanged(), tap(v => {
6052
6082
  if (v) {
@@ -6162,7 +6192,7 @@ class NgVirtualListComponent {
6162
6192
  }
6163
6193
  };
6164
6194
  let prevItems = [];
6165
- const debouncedUpdate = debounce(update, 0);
6195
+ const debouncedUpdate = debounce(update, 0, MAX_NUMBERS_OF_SKIPS_FOR_QUALITY_OPTIMIZATION_LVL1);
6166
6196
  $viewInit.pipe(takeUntilDestroyed(), filter$1(v => !!v), switchMap$1(() => {
6167
6197
  return combineLatest([$snapScrollToStart, $snapScrollToEnd, $bounds, $listBounds, $scrollEndOffset, $actualItems, $itemConfigMap, $scrollSize, $itemSize,
6168
6198
  $collapsedItemIds, $bufferSize, $maxBufferSize, $snap, $isVertical, $dynamicSize, $enabledBufferOptimization, $cacheVersion, this.$fireUpdate,