ng-virtual-list 21.9.4 → 21.9.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.
package/README.md CHANGED
@@ -751,6 +751,10 @@ Methods
751
751
  | scrollToEnd | (cb?: () => void, options?: [IScrollOptions](https://github.com/DjonnyX/ng-virtual-list/blob/21.x/projects/ng-virtual-list/src/lib/models/scroll-options.model.ts)) | Scrolls the scroll area to the last item in the collection. |
752
752
  | getItemBounds | (id: [Id](https://github.com/DjonnyX/ng-virtual-list/blob/21.x/projects/ng-virtual-list/src/lib/types/id.ts), behavior?: ScrollBehavior) => void | Returns the bounds of an element with a given id |
753
753
  | focus | [Id](https://github.com/DjonnyX/ng-virtual-list/blob/21.x/projects/ng-virtual-list/src/lib/types/id.ts), align: [FocusAlignment](https://github.com/DjonnyX/ng-virtual-list/blob/21.x/projects/ng-virtual-list/src/lib/types/focus-alignment.ts) = [FocusAlignments.NONE](https://github.com/DjonnyX/ng-virtual-list/blob/21.x/projects/ng-virtual-list/src/lib/enums/focus-alignments.ts) | Focus an list item by a given id. |
754
+ | cacheClean | | Force clearing the cache. |
755
+ | stopSnappingScrollToEnd | | Stops the list from snapping to the bottom edge. |
756
+ | updateImmediately | | Instantly refreshes the list. |
757
+ | markForUpdate | | Marks the list for an update that will trigger on the next tick. |
754
758
 
755
759
  <br/>
756
760
 
@@ -776,13 +780,13 @@ Properties
776
780
 
777
781
  | Angular version | ng-virtual-list version | git | npm |
778
782
  |--|--|--|--|
779
- | 20.x | 20.9.3 | [20.x](https://github.com/DjonnyX/ng-virtual-list/tree/20.x) | [20.9.3](https://www.npmjs.com/package/ng-virtual-list/v/20.9.3) |
780
- | 19.x | 19.9.5 | [19.x](https://github.com/DjonnyX/ng-virtual-list/tree/19.x) | [19.9.5](https://www.npmjs.com/package/ng-virtual-list/v/19.9.5) |
781
- | 18.x | 18.9.3 | [18.x](https://github.com/DjonnyX/ng-virtual-list/tree/18.x) | [18.9.3](https://www.npmjs.com/package/ng-virtual-list/v/18.9.3) |
782
- | 17.x | 17.9.3 | [17.x](https://github.com/DjonnyX/ng-virtual-list/tree/17.x) | [17.9.3](https://www.npmjs.com/package/ng-virtual-list/v/17.9.3) |
783
- | 16.x | 16.9.4 | [16.x](https://github.com/DjonnyX/ng-virtual-list/tree/16.x) | [16.9.4](https://www.npmjs.com/package/ng-virtual-list/v/16.9.4) |
784
- | 15.x | 15.9.4 | [15.x](https://github.com/DjonnyX/ng-virtual-list/tree/15.x) | [15.9.4](https://www.npmjs.com/package/ng-virtual-list/v/15.9.4) |
785
- | 14.x | 14.9.4 | [14.x](https://github.com/DjonnyX/ng-virtual-list/tree/14.x) | [14.9.4](https://www.npmjs.com/package/ng-virtual-list/v/14.9.4) |
783
+ | 20.x | 20.9.6 | [20.x](https://github.com/DjonnyX/ng-virtual-list/tree/20.x) | [20.9.6](https://www.npmjs.com/package/ng-virtual-list/v/20.9.6) |
784
+ | 19.x | 19.9.6 | [19.x](https://github.com/DjonnyX/ng-virtual-list/tree/19.x) | [19.9.6](https://www.npmjs.com/package/ng-virtual-list/v/19.9.6) |
785
+ | 18.x | 18.9.4 | [18.x](https://github.com/DjonnyX/ng-virtual-list/tree/18.x) | [18.9.4](https://www.npmjs.com/package/ng-virtual-list/v/18.9.4) |
786
+ | 17.x | 17.9.4 | [17.x](https://github.com/DjonnyX/ng-virtual-list/tree/17.x) | [17.9.4](https://www.npmjs.com/package/ng-virtual-list/v/17.9.4) |
787
+ | 16.x | 16.9.6 | [16.x](https://github.com/DjonnyX/ng-virtual-list/tree/16.x) | [16.9.6](https://www.npmjs.com/package/ng-virtual-list/v/16.9.6) |
788
+ | 15.x | 15.9.6 | [15.x](https://github.com/DjonnyX/ng-virtual-list/tree/15.x) | [15.9.6](https://www.npmjs.com/package/ng-virtual-list/v/15.9.6) |
789
+ | 14.x | 14.9.6 | [14.x](https://github.com/DjonnyX/ng-virtual-list/tree/14.x) | [14.9.6](https://www.npmjs.com/package/ng-virtual-list/v/14.9.6) |
786
790
 
787
791
  <br/>
788
792
 
@@ -345,8 +345,8 @@ class NgVirtualListService {
345
345
  this.select(data);
346
346
  }
347
347
  }
348
- update() {
349
- this._trackBox?.changes();
348
+ update(immediately = false) {
349
+ this._trackBox?.changes(immediately);
350
350
  }
351
351
  /**
352
352
  * Selects a list item
@@ -1202,14 +1202,14 @@ class CacheMap extends EventEmitter {
1202
1202
  }
1203
1203
  stopLifeCircle() {
1204
1204
  if (this._lifeCircleId !== undefined) {
1205
- cancelAnimationFrame(this._lifeCircleId);
1205
+ clearTimeout(this._lifeCircleId);
1206
1206
  }
1207
1207
  }
1208
1208
  nextTick(cb) {
1209
1209
  if (this._disposed) {
1210
1210
  return;
1211
1211
  }
1212
- this._lifeCircleId = requestAnimationFrame(() => {
1212
+ this._lifeCircleId = setTimeout(() => {
1213
1213
  cb();
1214
1214
  });
1215
1215
  return this._lifeCircleId;
@@ -2186,8 +2186,15 @@ class TrackBox extends CacheMap {
2186
2186
  this.clearScrollDirectionCache();
2187
2187
  }
2188
2188
  }
2189
- changes() {
2189
+ changes(immediately = false) {
2190
+ if (this.changesDetected()) {
2191
+ return;
2192
+ }
2190
2193
  this.bumpVersion();
2194
+ if (immediately) {
2195
+ this._previousVersion = this._version;
2196
+ this.dispatch(CACHE_BOX_CHANGE_EVENT_NAME, this.version);
2197
+ }
2191
2198
  }
2192
2199
  generateDisplayCollection(items, itemConfigMap, metrics) {
2193
2200
  const { offsetY, offsetX, width, height, normalizedItemWidth, normalizedItemHeight, dynamicSize, itemsOnDisplayLength, itemsFromStartToScrollEnd, isVertical, renderItems: renderItemsLength, scrollSize, sizeProperty, snap, snippedPos, startPosition, totalLength, startIndex, typicalItemSize, } = metrics, displayItems = [];
@@ -4531,20 +4538,24 @@ class NgVirtualListComponent {
4531
4538
  scrollerComponent.prepared = true;
4532
4539
  }
4533
4540
  this.classes.set({ prepared: true, [READY_TO_START]: true, [WAIT_FOR_PREPARATION]: waitForPreparation });
4541
+ this.updateImmediately();
4534
4542
  }
4535
4543
  }
4536
4544
  }), filter$1(v => !!v), delay(0), takeUntilDestroyed(this._destroyRef), tap(v => {
4537
4545
  prepared = v;
4546
+ this.updateImmediately();
4538
4547
  }), delay(0), takeUntilDestroyed(this._destroyRef), tap(v => {
4539
4548
  const waitForPreparation = this.waitForPreparation(), scrollerComponent = this._scrollerComponent(), val = v || !waitForPreparation;
4540
4549
  if (scrollerComponent) {
4541
4550
  scrollerComponent.prepared = val;
4542
4551
  }
4543
4552
  this.classes.set({ prepared: val, [WAIT_FOR_PREPARATION]: waitForPreparation });
4553
+ this.updateImmediately();
4544
4554
  }), delay(1000), takeUntilDestroyed(this._destroyRef), tap(v => {
4545
4555
  const waitForPreparation = this.waitForPreparation();
4546
4556
  readyToStart = v;
4547
4557
  this.classes.set({ prepared: true, [READY_TO_START]: true, [WAIT_FOR_PREPARATION]: waitForPreparation });
4558
+ this.updateImmediately();
4548
4559
  })).subscribe();
4549
4560
  this._service.$focusedId.pipe(takeUntilDestroyed(), tap(v => {
4550
4561
  this.focusedElement.set(v ?? undefined);
@@ -4907,8 +4918,7 @@ class NgVirtualListComponent {
4907
4918
  snap: this.snap(), fromItemId: id, enabledBufferOptimization: this.enabledBufferOptimization(),
4908
4919
  }, scrollSize = this._trackBox.getItemPosition(id, itemConfigMap, opts), params = {
4909
4920
  [isVertical ? TOP_PROP_NAME : LEFT_PROP_NAME]: scrollSize, behavior: BEHAVIOR_INSTANT,
4910
- fireUpdate: false,
4911
- blending: true,
4921
+ fireUpdate: false, blending: false,
4912
4922
  };
4913
4923
  if (scrollSize === -1) {
4914
4924
  return of([true, { id, scroller: scrollerComponent, scrollCalled, cb }]);
@@ -4951,7 +4961,7 @@ class NgVirtualListComponent {
4951
4961
  _$scrollToEndDuringUpdateCanceller.next(1);
4952
4962
  const params = {
4953
4963
  [this._isVertical ? TOP_PROP_NAME : LEFT_PROP_NAME]: scrollSize,
4954
- behavior: BEHAVIOR_INSTANT, blending: true,
4964
+ behavior: BEHAVIOR_INSTANT, blending: false,
4955
4965
  };
4956
4966
  scrollerComponent?.scrollTo?.(params);
4957
4967
  return of([true, { id, scroller: scrollerComponent, cb }]).pipe(delay(1));
@@ -5191,6 +5201,9 @@ class NgVirtualListComponent {
5191
5201
  this._trackBox.changes();
5192
5202
  }
5193
5203
  }
5204
+ /**
5205
+ * Force clearing the cache.
5206
+ */
5194
5207
  cacheClean() {
5195
5208
  this._trackBox.cacheClean();
5196
5209
  this._collapsedItemIds.set([]);
@@ -5204,6 +5217,9 @@ class NgVirtualListComponent {
5204
5217
  }
5205
5218
  this._$prepared.next(false);
5206
5219
  }
5220
+ /**
5221
+ * Stops the list from snapping to the bottom edge.
5222
+ */
5207
5223
  stopSnappingScrollToEnd() {
5208
5224
  const scroller = this._scrollerComponent();
5209
5225
  this._isScrollFinished.set(false);
@@ -5212,6 +5228,18 @@ class NgVirtualListComponent {
5212
5228
  scroller.stopScrolling();
5213
5229
  }
5214
5230
  }
5231
+ /**
5232
+ * Instantly refreshes the list.
5233
+ */
5234
+ updateImmediately() {
5235
+ this._service.update(true);
5236
+ }
5237
+ /**
5238
+ * Marks the list for an update that will trigger on the next tick.
5239
+ */
5240
+ markForUpdate() {
5241
+ this._service.update();
5242
+ }
5215
5243
  ngOnDestroy() {
5216
5244
  this.dispose();
5217
5245
  }