ng-virtual-list 20.9.4 → 20.9.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/README.md +4 -0
- package/fesm2022/ng-virtual-list.mjs +34 -6
- package/fesm2022/ng-virtual-list.mjs.map +1 -1
- package/index.d.ts +16 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -700,6 +700,10 @@ Methods
|
|
|
700
700
|
| scrollToEnd | (cb?: () => void, options?: [IScrollOptions](https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/models/scroll-options.model.ts)) | Scrolls the scroll area to the last item in the collection. |
|
|
701
701
|
| getItemBounds | (id: [Id](https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/types/id.ts), behavior?: ScrollBehavior) => void | Returns the bounds of an element with a given id |
|
|
702
702
|
| focus | [Id](https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/types/id.ts), align: [FocusAlignment](https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/types/focus-alignment.ts) = [FocusAlignments.NONE](https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/enums/focus-alignments.ts) | Focus an list item by a given id. |
|
|
703
|
+
| cacheClean | | Force clearing the cache. |
|
|
704
|
+
| stopSnappingScrollToEnd | | Stops the list from snapping to the bottom edge. |
|
|
705
|
+
| updateImmediately | | Instantly refreshes the list. |
|
|
706
|
+
| markForUpdate | | Marks the list for an update that will trigger on the next tick. |
|
|
703
707
|
|
|
704
708
|
<br/>
|
|
705
709
|
|
|
@@ -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
|
|
@@ -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 = [];
|
|
@@ -4533,20 +4540,24 @@ class NgVirtualListComponent {
|
|
|
4533
4540
|
scrollerComponent.prepared = true;
|
|
4534
4541
|
}
|
|
4535
4542
|
this.classes.set({ prepared: true, [READY_TO_START]: true, [WAIT_FOR_PREPARATION]: waitForPreparation });
|
|
4543
|
+
this.updateImmediately();
|
|
4536
4544
|
}
|
|
4537
4545
|
}
|
|
4538
4546
|
}), filter$1(v => !!v), delay(0), takeUntilDestroyed(this._destroyRef), tap(v => {
|
|
4539
4547
|
prepared = v;
|
|
4548
|
+
this.updateImmediately();
|
|
4540
4549
|
}), delay(0), takeUntilDestroyed(this._destroyRef), tap(v => {
|
|
4541
4550
|
const waitForPreparation = this.waitForPreparation(), scrollerComponent = this._scrollerComponent(), val = v || !waitForPreparation;
|
|
4542
4551
|
if (scrollerComponent) {
|
|
4543
4552
|
scrollerComponent.prepared = val;
|
|
4544
4553
|
}
|
|
4545
4554
|
this.classes.set({ prepared: val, [WAIT_FOR_PREPARATION]: waitForPreparation });
|
|
4555
|
+
this.updateImmediately();
|
|
4546
4556
|
}), delay(1000), takeUntilDestroyed(this._destroyRef), tap(v => {
|
|
4547
4557
|
const waitForPreparation = this.waitForPreparation();
|
|
4548
4558
|
readyToStart = v;
|
|
4549
4559
|
this.classes.set({ prepared: true, [READY_TO_START]: true, [WAIT_FOR_PREPARATION]: waitForPreparation });
|
|
4560
|
+
this.updateImmediately();
|
|
4550
4561
|
})).subscribe();
|
|
4551
4562
|
this._service.$focusedId.pipe(takeUntilDestroyed(), tap(v => {
|
|
4552
4563
|
this.focusedElement.set(v ?? undefined);
|
|
@@ -4909,8 +4920,7 @@ class NgVirtualListComponent {
|
|
|
4909
4920
|
snap: this.snap(), fromItemId: id, enabledBufferOptimization: this.enabledBufferOptimization(),
|
|
4910
4921
|
}, scrollSize = this._trackBox.getItemPosition(id, itemConfigMap, opts), params = {
|
|
4911
4922
|
[isVertical ? TOP_PROP_NAME : LEFT_PROP_NAME]: scrollSize, behavior: BEHAVIOR_INSTANT,
|
|
4912
|
-
fireUpdate: false,
|
|
4913
|
-
blending: true,
|
|
4923
|
+
fireUpdate: false, blending: false,
|
|
4914
4924
|
};
|
|
4915
4925
|
if (scrollSize === -1) {
|
|
4916
4926
|
return of([true, { id, scroller: scrollerComponent, scrollCalled, cb }]);
|
|
@@ -4953,7 +4963,7 @@ class NgVirtualListComponent {
|
|
|
4953
4963
|
_$scrollToEndDuringUpdateCanceller.next(1);
|
|
4954
4964
|
const params = {
|
|
4955
4965
|
[this._isVertical ? TOP_PROP_NAME : LEFT_PROP_NAME]: scrollSize,
|
|
4956
|
-
behavior: BEHAVIOR_INSTANT, blending:
|
|
4966
|
+
behavior: BEHAVIOR_INSTANT, blending: false,
|
|
4957
4967
|
};
|
|
4958
4968
|
scrollerComponent?.scrollTo?.(params);
|
|
4959
4969
|
return of([true, { id, scroller: scrollerComponent, cb }]).pipe(delay(1));
|
|
@@ -5193,6 +5203,9 @@ class NgVirtualListComponent {
|
|
|
5193
5203
|
this._trackBox.changes();
|
|
5194
5204
|
}
|
|
5195
5205
|
}
|
|
5206
|
+
/**
|
|
5207
|
+
* Force clearing the cache.
|
|
5208
|
+
*/
|
|
5196
5209
|
cacheClean() {
|
|
5197
5210
|
this._trackBox.cacheClean();
|
|
5198
5211
|
this._collapsedItemIds.set([]);
|
|
@@ -5206,6 +5219,9 @@ class NgVirtualListComponent {
|
|
|
5206
5219
|
}
|
|
5207
5220
|
this._$prepared.next(false);
|
|
5208
5221
|
}
|
|
5222
|
+
/**
|
|
5223
|
+
* Stops the list from snapping to the bottom edge.
|
|
5224
|
+
*/
|
|
5209
5225
|
stopSnappingScrollToEnd() {
|
|
5210
5226
|
const scroller = this._scrollerComponent();
|
|
5211
5227
|
this._isScrollFinished.set(false);
|
|
@@ -5214,6 +5230,18 @@ class NgVirtualListComponent {
|
|
|
5214
5230
|
scroller.stopScrolling();
|
|
5215
5231
|
}
|
|
5216
5232
|
}
|
|
5233
|
+
/**
|
|
5234
|
+
* Instantly refreshes the list.
|
|
5235
|
+
*/
|
|
5236
|
+
updateImmediately() {
|
|
5237
|
+
this._service.update(true);
|
|
5238
|
+
}
|
|
5239
|
+
/**
|
|
5240
|
+
* Marks the list for an update that will trigger on the next tick.
|
|
5241
|
+
*/
|
|
5242
|
+
markForUpdate() {
|
|
5243
|
+
this._service.update();
|
|
5244
|
+
}
|
|
5217
5245
|
ngOnDestroy() {
|
|
5218
5246
|
this.dispose();
|
|
5219
5247
|
}
|