ng-virtual-list 20.10.14 → 20.10.16

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.
@@ -4538,9 +4538,9 @@ class NgVirtualListComponent {
4538
4538
  maxBufferSize = input(DEFAULT_MAX_BUFFER_SIZE, ...(ngDevMode ? [{ debugName: "maxBufferSize", ...this._maxBufferSizeTransform }] : [{ ...this._maxBufferSizeTransform }]));
4539
4539
  _snappingMethodOptions = {
4540
4540
  transform: (v) => {
4541
- const valid = validateString(v) && (v === 'normal' || v === 'advanced' || 'chat');
4541
+ const valid = validateString(v) && (v === SnappingMethods.NORMAL || v === SnappingMethods.ADVANCED || v === SnappingMethods.CHAT);
4542
4542
  if (!valid) {
4543
- console.error('The "snappingMethod" parameter must have the value `normal`, `advanced` or `chat`.');
4543
+ console.error(`The "snappingMethod" parameter must have the value '${SnappingMethods.NORMAL}', '${SnappingMethods.ADVANCED}' or '${SnappingMethods.CHAT}'.`);
4544
4544
  return DEFAULT_SNAPPING_METHOD;
4545
4545
  }
4546
4546
  return v;
@@ -4882,7 +4882,7 @@ class NgVirtualListComponent {
4882
4882
  this.cacheClean();
4883
4883
  this._readyToShow = this._isUserScrolling = false;
4884
4884
  this.refreshActualItemSize(false);
4885
- if (this.snapScrollToBottom()) {
4885
+ if (snapScrollToBottom) {
4886
4886
  this._trackBox.isScrollEnd = true;
4887
4887
  }
4888
4888
  this._updateIterations = 0;
@@ -4895,7 +4895,7 @@ class NgVirtualListComponent {
4895
4895
  this.classes.set({ prepared: false, [READY_TO_START]: false, [WAIT_FOR_PREPARATION]: false });
4896
4896
  this._$show.next(false);
4897
4897
  }
4898
- this._trackBox.resetCollection(items, this.itemSize());
4898
+ this._trackBox.resetCollection(items, this.actualItemSize());
4899
4899
  }), map(i => (i ?? []).length > 0), distinctUntilChanged(), switchMap$1(v => {
4900
4900
  if (!v) {
4901
4901
  return of(false);
@@ -4931,26 +4931,31 @@ class NgVirtualListComponent {
4931
4931
  }));
4932
4932
  }
4933
4933
  else {
4934
- this._readyToShow = true;
4935
- this.refreshActualItemSize(true);
4936
- const scrollerComponent = this._scrollerComponent();
4937
- if (scrollerComponent) {
4938
- scrollerComponent.prepared = true;
4939
- scrollerComponent.stopScrolling();
4940
- }
4941
- this.classes.set({ prepared: true, [READY_TO_START]: true, [WAIT_FOR_PREPARATION]: false });
4942
- this._service.update(true);
4943
- this._$show.next(true);
4944
- this._scrollerComponent()?.refresh(true, true);
4945
4934
  return $items.pipe(takeUntilDestroyed(this._destroyRef), debounceTime(0), tap(items => {
4946
4935
  if (!items || items.length === 0) {
4947
4936
  this.cacheClean();
4937
+ const scrollerComponent = this._scrollerComponent();
4938
+ if (scrollerComponent) {
4939
+ scrollerComponent.prepared = false;
4940
+ scrollerComponent.stopScrolling();
4941
+ }
4942
+ this.classes.set({ prepared: false, [READY_TO_START]: false, [WAIT_FOR_PREPARATION]: false });
4943
+ this._$show.next(false);
4944
+ }
4945
+ this._trackBox.resetCollection(items, this.actualItemSize());
4946
+ }), map(i => (i ?? []).length > 0), distinctUntilChanged(), filter$1(v => !!v), tap(() => {
4947
+ this._readyToShow = true;
4948
+ this.refreshActualItemSize(false);
4949
+ if (snapScrollToBottom) {
4950
+ this._trackBox.isScrollEnd = true;
4948
4951
  }
4949
- this._trackBox.resetCollection(items, this.itemSize());
4950
4952
  const scrollerComponent = this._scrollerComponent();
4951
4953
  if (scrollerComponent) {
4952
4954
  scrollerComponent.prepared = true;
4953
4955
  }
4956
+ this.classes.set({ prepared: true, [READY_TO_START]: true, [WAIT_FOR_PREPARATION]: true });
4957
+ this._$show.next(true);
4958
+ this._$fireUpdate.next();
4954
4959
  }));
4955
4960
  ;
4956
4961
  }
@@ -5010,7 +5015,10 @@ class NgVirtualListComponent {
5010
5015
  $trackBy.pipe(takeUntilDestroyed(), tap(v => {
5011
5016
  this._trackBox.trackingPropertyName = v;
5012
5017
  })).subscribe();
5013
- const $bounds = toObservable(this._bounds).pipe(filter$1(b => !!b)), $listBounds = toObservable(this._listBounds).pipe(filter$1(b => !!b)), $scrollSize = toObservable(this._scrollSize), $itemSize = toObservable(this.actualItemSize).pipe(map(v => v <= 0 ? DEFAULT_ITEM_SIZE : v)), $bufferSize = toObservable(this.bufferSize).pipe(map(v => v < 0 ? DEFAULT_BUFFER_SIZE : v)), $maxBufferSize = toObservable(this.maxBufferSize).pipe(map(v => v < 0 ? DEFAULT_BUFFER_SIZE : v)), $itemConfigMap = toObservable(this.itemConfigMap).pipe(map(v => !v ? {} : v)), $snap = toObservable(this.snap), $isLazy = toObservable(this.collectionMode).pipe(map(v => this.getIsLazy(v || DEFAULT_COLLECTION_MODE))), $enabledBufferOptimization = toObservable(this.enabledBufferOptimization), $snappingMethod = toObservable(this.snappingMethod).pipe(map(v => this.getIsSnappingMethodAdvanced(v || DEFAULT_SNAPPING_METHOD))), $methodForSelecting = toObservable(this.methodForSelecting), $selectedIds = toObservable(this.selectedIds), $collapsedIds = toObservable(this.collapsedIds).pipe(map(v => Array.isArray(v) ? v : [])), $collapsedItemIds = toObservable(this._collapsedItemIds).pipe(map(v => Array.isArray(v) ? v : [])), $actualItems = toObservable(this._actualItems), $screenReaderMessage = toObservable(this.screenReaderMessage), $displayItems = this._service.$displayItems, $cacheVersion = toObservable(this._cacheVersion);
5018
+ const $bounds = toObservable(this._bounds).pipe(filter$1(b => !!b)), $listBounds = toObservable(this._listBounds).pipe(filter$1(b => !!b)), $scrollSize = toObservable(this._scrollSize), $itemSize = toObservable(this.itemSize).pipe(map(v => v <= 0 ? DEFAULT_ITEM_SIZE : v)), $actualItemSize = toObservable(this.actualItemSize).pipe(map(v => v <= 0 ? DEFAULT_ITEM_SIZE : v)), $bufferSize = toObservable(this.bufferSize).pipe(map(v => v < 0 ? DEFAULT_BUFFER_SIZE : v)), $maxBufferSize = toObservable(this.maxBufferSize).pipe(map(v => v < 0 ? DEFAULT_BUFFER_SIZE : v)), $itemConfigMap = toObservable(this.itemConfigMap).pipe(map(v => !v ? {} : v)), $snap = toObservable(this.snap), $isLazy = toObservable(this.collectionMode).pipe(map(v => this.getIsLazy(v || DEFAULT_COLLECTION_MODE))), $enabledBufferOptimization = toObservable(this.enabledBufferOptimization), $snappingMethod = toObservable(this.snappingMethod).pipe(map(v => this.getIsSnappingMethodAdvanced(v || DEFAULT_SNAPPING_METHOD))), $methodForSelecting = toObservable(this.methodForSelecting), $selectedIds = toObservable(this.selectedIds), $collapsedIds = toObservable(this.collapsedIds).pipe(map(v => Array.isArray(v) ? v : [])), $collapsedItemIds = toObservable(this._collapsedItemIds).pipe(map(v => Array.isArray(v) ? v : [])), $actualItems = toObservable(this._actualItems), $screenReaderMessage = toObservable(this.screenReaderMessage), $displayItems = this._service.$displayItems, $cacheVersion = toObservable(this._cacheVersion);
5019
+ $itemSize.pipe(takeUntilDestroyed(), distinctUntilChanged(), tap(size => {
5020
+ this.actualItemSize.set(size);
5021
+ })).subscribe();
5014
5022
  combineLatest([$displayItems, $screenReaderMessage, $isVertical, $scrollSize, $bounds]).pipe(takeUntilDestroyed(), distinctUntilChanged(), debounceTime(100), takeUntilDestroyed(), tap(([items, screenReaderMessage, isVertical, scrollSize, bounds]) => {
5015
5023
  this.screenReaderFormattedMessage.set(formatScreenReaderMessage(items, screenReaderMessage, scrollSize, isVertical, bounds));
5016
5024
  })).subscribe();
@@ -5193,7 +5201,7 @@ class NgVirtualListComponent {
5193
5201
  }
5194
5202
  };
5195
5203
  $viewInit.pipe(takeUntilDestroyed(), filter$1(v => !!v), switchMap$1(() => {
5196
- return combineLatest([$snapScrollToBottom, $bounds, $listBounds, $scrollEndOffset, $actualItems, $itemConfigMap, $scrollSize, $itemSize,
5204
+ return combineLatest([$snapScrollToBottom, $bounds, $listBounds, $scrollEndOffset, $actualItems, $itemConfigMap, $scrollSize, $actualItemSize,
5197
5205
  $bufferSize, $maxBufferSize, $snap, $isVertical, $dynamicSize, $enabledBufferOptimization, $cacheVersion, this.$fireUpdate,
5198
5206
  ]).pipe(takeUntilDestroyed(this._destroyRef), distinctUntilChanged(), tap(([snapScrollToBottom, bounds, listBounds, scrollEndOffset, items, itemConfigMap, scrollSize, itemSize, bufferSize, maxBufferSize, snap, isVertical, dynamicSize, enabledBufferOptimization, cacheVersion,]) => {
5199
5207
  update({
@@ -5520,12 +5528,12 @@ class NgVirtualListComponent {
5520
5528
  }
5521
5529
  }
5522
5530
  refreshActualItemSize(value) {
5523
- if (!this.waitForPreparation()) {
5531
+ if (!this.waitForPreparation() || !this.dynamicSize()) {
5524
5532
  return;
5525
5533
  }
5526
5534
  let size;
5527
- const bounds = this._bounds();
5528
- if (value === false) {
5535
+ const bounds = this._bounds(), dynamicSize = this.dynamicSize();
5536
+ if (dynamicSize && value === false) {
5529
5537
  size = (this._isVertical ?
5530
5538
  bounds?.height || DEFAULT_LIST_SIZE :
5531
5539
  bounds?.width || DEFAULT_LIST_SIZE);
@@ -5704,7 +5712,9 @@ class NgVirtualListComponent {
5704
5712
  * Force clearing the cache.
5705
5713
  */
5706
5714
  cacheClean() {
5707
- this._trackBox.cacheClean();
5715
+ if (this.dynamicSize()) {
5716
+ this._trackBox.cacheClean();
5717
+ }
5708
5718
  this._collapsedItemIds.set([]);
5709
5719
  this._isScrollStart.set(true);
5710
5720
  this._isScrollFinished.set(false);