ng-virtual-list 20.10.12 → 20.10.14
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 +42 -46
- package/fesm2022/ng-virtual-list.mjs.map +1 -1
- package/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -142,7 +142,7 @@ const TRACK_BY_PROPERTY_NAME = 'id';
|
|
|
142
142
|
const DEFAULT_DIRECTION = Directions.VERTICAL;
|
|
143
143
|
const DEFAULT_COLLECTION_MODE = CollectionModes.NORMAL;
|
|
144
144
|
const DISPLAY_OBJECTS_LENGTH_MESUREMENT_ERROR = 1;
|
|
145
|
-
const MAX_SCROLL_TO_ITERATIONS =
|
|
145
|
+
const MAX_SCROLL_TO_ITERATIONS = 7;
|
|
146
146
|
const DEFAULT_SNAPPING_METHOD = SnappingMethods.NORMAL;
|
|
147
147
|
const DEFAULT_SELECT_METHOD = MethodsForSelecting.NONE;
|
|
148
148
|
const DEFAULT_SCREEN_READER_MESSAGE = 'Showing items $1 to $2';
|
|
@@ -3111,7 +3111,7 @@ class NgScrollView {
|
|
|
3111
3111
|
set totalSize(v) {
|
|
3112
3112
|
this._totalSize = v;
|
|
3113
3113
|
}
|
|
3114
|
-
_startPosition =
|
|
3114
|
+
_startPosition = 0;
|
|
3115
3115
|
get actualScrollHeight() {
|
|
3116
3116
|
const { height: viewportHeight } = this.viewportBounds(), totalSize = this._totalSize;
|
|
3117
3117
|
if (this._inversion) {
|
|
@@ -3829,10 +3829,10 @@ class NgScrollerComponent extends NgScrollView {
|
|
|
3829
3829
|
if (update) {
|
|
3830
3830
|
this.scrollBar?.scroll({
|
|
3831
3831
|
[isVertical ? TOP_PROP_NAME : LEFT_PROP_NAME]: thumbPosition, fireUpdate: false, behavior: BEHAVIOR_INSTANT,
|
|
3832
|
-
userAction: false, blending:
|
|
3832
|
+
userAction: false, blending: true,
|
|
3833
3833
|
});
|
|
3834
3834
|
}
|
|
3835
|
-
this.scrollbarShow.set(
|
|
3835
|
+
this.scrollbarShow.set(this.scrollable);
|
|
3836
3836
|
}
|
|
3837
3837
|
;
|
|
3838
3838
|
ngAfterViewInit() {
|
|
@@ -3843,18 +3843,14 @@ class NgScrollerComponent extends NgScrollView {
|
|
|
3843
3843
|
}
|
|
3844
3844
|
onDragStart() {
|
|
3845
3845
|
super.onDragStart();
|
|
3846
|
-
|
|
3847
|
-
this.scrollBar.stopScrolling();
|
|
3848
|
-
}
|
|
3846
|
+
this.stopScrollbar();
|
|
3849
3847
|
this._isScrollbarUserAction = false;
|
|
3850
3848
|
this.updateScrollBar();
|
|
3851
3849
|
}
|
|
3852
3850
|
reset() {
|
|
3853
3851
|
super.reset(this.startOffset());
|
|
3854
3852
|
this.totalSize = 0;
|
|
3855
|
-
|
|
3856
|
-
this.scrollBar.stopScrolling();
|
|
3857
|
-
}
|
|
3853
|
+
this.stopScrollbar();
|
|
3858
3854
|
this.refresh(true, true);
|
|
3859
3855
|
this.prepared = false;
|
|
3860
3856
|
}
|
|
@@ -3880,13 +3876,16 @@ class NgScrollerComponent extends NgScrollView {
|
|
|
3880
3876
|
scrollTo(params) {
|
|
3881
3877
|
const userAction = params.userAction ?? true, blending = params.blending ?? true, fireUpdate = params.fireUpdate ?? false;
|
|
3882
3878
|
if (userAction && (!blending && !this._isMoving) && !fireUpdate) {
|
|
3883
|
-
|
|
3884
|
-
this.scrollBar.stopScrolling();
|
|
3885
|
-
}
|
|
3879
|
+
this.stopScrollbar();
|
|
3886
3880
|
this._isScrollbarUserAction = false;
|
|
3887
3881
|
}
|
|
3888
3882
|
this.scroll(params);
|
|
3889
3883
|
}
|
|
3884
|
+
stopScrollbar() {
|
|
3885
|
+
if (!!this.scrollBar) {
|
|
3886
|
+
this.scrollBar.stopScrolling();
|
|
3887
|
+
}
|
|
3888
|
+
}
|
|
3890
3889
|
onScrollBarDragHandler(event) {
|
|
3891
3890
|
const { animation, position, min, max, userAction } = event;
|
|
3892
3891
|
this._isScrollbarUserAction = userAction;
|
|
@@ -3929,7 +3928,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.17", ngImpo
|
|
|
3929
3928
|
args: ['scrollBar', { read: NgScrollBarComponent }]
|
|
3930
3929
|
}], scrollbarEnabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "scrollbarEnabled", required: false }] }], scrollbarInteractive: [{ type: i0.Input, args: [{ isSignal: true, alias: "scrollbarInteractive", required: false }] }], focusedElement: [{ type: i0.Input, args: [{ isSignal: true, alias: "focusedElement", required: false }] }], content: [{ type: i0.Input, args: [{ isSignal: true, alias: "content", required: false }] }], loading: [{ type: i0.Input, args: [{ isSignal: true, alias: "loading", required: false }] }], classes: [{ type: i0.Input, args: [{ isSignal: true, alias: "classes", required: false }] }], startOffset: [{ type: i0.Input, args: [{ isSignal: true, alias: "startOffset", required: false }] }], endOffset: [{ type: i0.Input, args: [{ isSignal: true, alias: "endOffset", required: false }] }], scrollbarTheme: [{ type: i0.Input, args: [{ isSignal: true, alias: "scrollbarTheme", required: false }] }], scrollbarMinSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "scrollbarMinSize", required: false }] }] } });
|
|
3931
3930
|
|
|
3932
|
-
const MIN_SCROLL_TO_START_PIXELS = 10, RANGE_DISPLAY_ITEMS_END_OFFSET = 20, MIN_PREPARE_ITERATIONS =
|
|
3931
|
+
const MIN_SCROLL_TO_START_PIXELS = 10, RANGE_DISPLAY_ITEMS_END_OFFSET = 20, MIN_PREPARE_ITERATIONS = 5, PREPARATION_REUPDATE_LENGTH = 2, EMPTY_SCROLL_STATE_VERSION = '-1', ROLE_LIST = 'list', ROLE_LIST_BOX = 'listbox', ITEM_ID = 'item-id', ITEM_CONTAINER = 'ngvl-item__container', READY_TO_START = 'ready-to-start', WAIT_FOR_PREPARATION = 'wait-for-preparation';
|
|
3933
3932
|
const validateScrollIteration = (value) => {
|
|
3934
3933
|
return Number.isNaN(value) || (value < 0) ? 0 : value > MAX_SCROLL_TO_ITERATIONS ? MAX_SCROLL_TO_ITERATIONS : value;
|
|
3935
3934
|
}, validateId = (id) => {
|
|
@@ -4856,33 +4855,18 @@ class NgVirtualListComponent {
|
|
|
4856
4855
|
}
|
|
4857
4856
|
if (this._prevScrollStateVersion === v) {
|
|
4858
4857
|
this._trackBox.isScrollEnd = true;
|
|
4859
|
-
if (this._updateIterations === RESET_CACHE_FRAME_NUMBER) {
|
|
4860
|
-
this.refreshActualItemSize(true);
|
|
4861
|
-
}
|
|
4862
4858
|
if (this._updateIterations < PREPARATION_REUPDATE_LENGTH) {
|
|
4863
4859
|
this._updateIterations++;
|
|
4864
|
-
this._trackBox.isScrollEnd = true;
|
|
4865
4860
|
this._$fireUpdate.next();
|
|
4866
4861
|
return of(false);
|
|
4867
4862
|
}
|
|
4868
4863
|
}
|
|
4869
4864
|
this._prevScrollStateVersion = v;
|
|
4865
|
+
this.refreshActualItemSize(false);
|
|
4870
4866
|
return of(true);
|
|
4871
4867
|
}), filter$1(v => !!v), distinctUntilChanged()), $items = toObservable(this.items), $dynamicSize = toObservable(this.dynamicSize);
|
|
4872
4868
|
const $viewInit = this.$viewInit, $snapScrollToBottom = toObservable(this.snapScrollToBottom), $waitForPreparation = toObservable(this.waitForPreparation);
|
|
4873
|
-
combineLatest([$dynamicSize, $snapScrollToBottom, $waitForPreparation]).pipe(takeUntilDestroyed(this._destroyRef), distinctUntilChanged(), switchMap$1(([dynamicSize, snapScrollToBottom, waitForPreparation]) => {
|
|
4874
|
-
if (!dynamicSize || !snapScrollToBottom || !waitForPreparation) {
|
|
4875
|
-
this._readyToShow = true;
|
|
4876
|
-
this.refreshActualItemSize(true);
|
|
4877
|
-
const scrollerComponent = this._scrollerComponent();
|
|
4878
|
-
if (scrollerComponent) {
|
|
4879
|
-
scrollerComponent.prepared = true;
|
|
4880
|
-
}
|
|
4881
|
-
this.classes.set({ prepared: true, [READY_TO_START]: true, [WAIT_FOR_PREPARATION]: false });
|
|
4882
|
-
this._service.update();
|
|
4883
|
-
this._$show.next(true);
|
|
4884
|
-
return of(false);
|
|
4885
|
-
}
|
|
4869
|
+
combineLatest([$viewInit, $dynamicSize, $snapScrollToBottom, $waitForPreparation]).pipe(takeUntilDestroyed(this._destroyRef), distinctUntilChanged(), filter$1(([init]) => !!init), switchMap$1(([, dynamicSize, snapScrollToBottom, waitForPreparation]) => {
|
|
4886
4870
|
if (!!dynamicSize && !!snapScrollToBottom && !!waitForPreparation) {
|
|
4887
4871
|
this._$show.next(false);
|
|
4888
4872
|
this.cacheClean();
|
|
@@ -4893,12 +4877,14 @@ class NgVirtualListComponent {
|
|
|
4893
4877
|
scrollerComponent.stopScrolling();
|
|
4894
4878
|
}
|
|
4895
4879
|
this.classes.set({ prepared: false, [READY_TO_START]: false, [WAIT_FOR_PREPARATION]: false });
|
|
4896
|
-
return $items.pipe(takeUntilDestroyed(this._destroyRef), debounceTime(0),
|
|
4897
|
-
if (!
|
|
4880
|
+
return $items.pipe(takeUntilDestroyed(this._destroyRef), debounceTime(0), tap(items => {
|
|
4881
|
+
if (!items || items.length === 0) {
|
|
4898
4882
|
this.cacheClean();
|
|
4899
4883
|
this._readyToShow = this._isUserScrolling = false;
|
|
4900
4884
|
this.refreshActualItemSize(false);
|
|
4901
|
-
this.
|
|
4885
|
+
if (this.snapScrollToBottom()) {
|
|
4886
|
+
this._trackBox.isScrollEnd = true;
|
|
4887
|
+
}
|
|
4902
4888
|
this._updateIterations = 0;
|
|
4903
4889
|
this._prevScrollStateVersion = EMPTY_SCROLL_STATE_VERSION;
|
|
4904
4890
|
const scrollerComponent = this._scrollerComponent();
|
|
@@ -4908,6 +4894,10 @@ class NgVirtualListComponent {
|
|
|
4908
4894
|
}
|
|
4909
4895
|
this.classes.set({ prepared: false, [READY_TO_START]: false, [WAIT_FOR_PREPARATION]: false });
|
|
4910
4896
|
this._$show.next(false);
|
|
4897
|
+
}
|
|
4898
|
+
this._trackBox.resetCollection(items, this.itemSize());
|
|
4899
|
+
}), map(i => (i ?? []).length > 0), distinctUntilChanged(), switchMap$1(v => {
|
|
4900
|
+
if (!v) {
|
|
4911
4901
|
return of(false);
|
|
4912
4902
|
}
|
|
4913
4903
|
return of(true).pipe(takeUntilDestroyed(this._destroyRef), switchMap$1(() => {
|
|
@@ -4952,7 +4942,17 @@ class NgVirtualListComponent {
|
|
|
4952
4942
|
this._service.update(true);
|
|
4953
4943
|
this._$show.next(true);
|
|
4954
4944
|
this._scrollerComponent()?.refresh(true, true);
|
|
4955
|
-
return
|
|
4945
|
+
return $items.pipe(takeUntilDestroyed(this._destroyRef), debounceTime(0), tap(items => {
|
|
4946
|
+
if (!items || items.length === 0) {
|
|
4947
|
+
this.cacheClean();
|
|
4948
|
+
}
|
|
4949
|
+
this._trackBox.resetCollection(items, this.itemSize());
|
|
4950
|
+
const scrollerComponent = this._scrollerComponent();
|
|
4951
|
+
if (scrollerComponent) {
|
|
4952
|
+
scrollerComponent.prepared = true;
|
|
4953
|
+
}
|
|
4954
|
+
}));
|
|
4955
|
+
;
|
|
4956
4956
|
}
|
|
4957
4957
|
})).subscribe();
|
|
4958
4958
|
this._service.$focusedId.pipe(takeUntilDestroyed(), tap(v => {
|
|
@@ -5017,9 +5017,6 @@ class NgVirtualListComponent {
|
|
|
5017
5017
|
$isLazy.pipe(takeUntilDestroyed(), tap(v => {
|
|
5018
5018
|
this._trackBox.isLazy = v;
|
|
5019
5019
|
})).subscribe();
|
|
5020
|
-
$items.pipe(takeUntilDestroyed(), debounceTime(0), tap(items => {
|
|
5021
|
-
this._trackBox.resetCollection(items, this.actualItemSize());
|
|
5022
|
-
})).subscribe();
|
|
5023
5020
|
combineLatest([$items, $collapsedItemIds, $itemConfigMap, $trackBy]).pipe(takeUntilDestroyed(), debounceTime(0), tap(([items, collapsedIds, itemConfigMap, trackBy]) => {
|
|
5024
5021
|
const hiddenItems = new CMap();
|
|
5025
5022
|
let isCollapsed = false;
|
|
@@ -5137,7 +5134,8 @@ class NgVirtualListComponent {
|
|
|
5137
5134
|
this._isScrollFinished.set(scrollPosition >= roundedMaxPosition);
|
|
5138
5135
|
}
|
|
5139
5136
|
}
|
|
5140
|
-
actualScrollSize = !this._readyToShow && snapScrollToBottom
|
|
5137
|
+
actualScrollSize = ((!this._readyToShow && snapScrollToBottom) || this._trackBox.isSnappedToEnd) ?
|
|
5138
|
+
(isVertical ? scroller.scrollHeight ?? 0 : scroller.scrollWidth ?? 0) :
|
|
5141
5139
|
(isVertical ? scroller.scrollTop ?? 0 : scroller.scrollLeft ?? 0);
|
|
5142
5140
|
const delta = this._trackBox.delta, roundedActualScrollSize = Math.round(actualScrollSize), scrollPositionAfterUpdate = actualScrollSize + delta, roundedScrollPositionAfterUpdate = Math.round(scrollPositionAfterUpdate), roundedMaxPositionAfterUpdate = Math.round(totalSize - viewportSize);
|
|
5143
5141
|
if (this._isSnappingMethodAdvanced) {
|
|
@@ -5157,10 +5155,11 @@ class NgVirtualListComponent {
|
|
|
5157
5155
|
if (emitable && this._readyToShow) {
|
|
5158
5156
|
this.emitScrollEvent(true, false);
|
|
5159
5157
|
}
|
|
5160
|
-
if (
|
|
5158
|
+
if ((this._readyToShow && roundedMaxPositionAfterUpdate > 0) ||
|
|
5159
|
+
(roundedMaxPositionAfterUpdate >= 0 && this._scrollSize() !== roundedMaxPositionAfterUpdate)) {
|
|
5161
5160
|
const params = {
|
|
5162
5161
|
[isVertical ? TOP_PROP_NAME : LEFT_PROP_NAME]: roundedMaxPositionAfterUpdate,
|
|
5163
|
-
fireUpdate:
|
|
5162
|
+
fireUpdate: !this._readyToShow, behavior: BEHAVIOR_INSTANT,
|
|
5164
5163
|
blending: false, duration: this.animationParams().scrollToItem,
|
|
5165
5164
|
};
|
|
5166
5165
|
scroller?.scrollTo?.(params);
|
|
@@ -5179,7 +5178,7 @@ class NgVirtualListComponent {
|
|
|
5179
5178
|
if (this._scrollSize() !== scrollPositionAfterUpdate) {
|
|
5180
5179
|
const params = {
|
|
5181
5180
|
[isVertical ? TOP_PROP_NAME : LEFT_PROP_NAME]: scrollPositionAfterUpdate, blending: true,
|
|
5182
|
-
fireUpdate:
|
|
5181
|
+
fireUpdate: !this._readyToShow, behavior: BEHAVIOR_INSTANT, duration: this.animationParams().scrollToItem,
|
|
5183
5182
|
};
|
|
5184
5183
|
scroller.scrollTo(params);
|
|
5185
5184
|
if (emitable && !this._readyToShow) {
|
|
@@ -5203,9 +5202,6 @@ class NgVirtualListComponent {
|
|
|
5203
5202
|
});
|
|
5204
5203
|
}));
|
|
5205
5204
|
})).subscribe();
|
|
5206
|
-
combineLatest([$items, $dynamicSize]).pipe(takeUntilDestroyed(), debounceTime(0), filter$1(([, dynamic]) => !dynamic), delay(0), takeUntilDestroyed(), tap(() => {
|
|
5207
|
-
this._scrollerComponent()?.refresh(true);
|
|
5208
|
-
})).subscribe();
|
|
5209
5205
|
const $scroller = toObservable(this._scroller).pipe(takeUntilDestroyed(), filter$1(v => !!v), map(v => v.nativeElement), take(1)), $scrollerScroll = toObservable(this._scrollerComponent).pipe(takeUntilDestroyed(), filter$1(v => !!v), take(1), switchMap$1(scroller => scroller.$scroll)), $scrollerScrollEnd = toObservable(this._scrollerComponent).pipe(takeUntilDestroyed(), filter$1(v => !!v), take(1), switchMap$1(scroller => scroller.$scrollEnd)), $list = toObservable(this._list).pipe(takeUntilDestroyed(), filter$1(v => !!v), map(v => v.nativeElement), take(1));
|
|
5210
5206
|
$scroller.pipe(takeUntilDestroyed(), distinctUntilChanged(), switchMap$1(scroller => {
|
|
5211
5207
|
return fromEvent(scroller, SCROLLER_WHEEL, { passive: true }).pipe(takeUntilDestroyed(this._destroyRef), filter$1(() => {
|
|
@@ -5376,7 +5372,7 @@ class NgVirtualListComponent {
|
|
|
5376
5372
|
return of([false, {
|
|
5377
5373
|
id, scroller: scrollerComponent, iteration: iteration + 1, blending,
|
|
5378
5374
|
isLastIteration: notChanged, scrollCalled: true, cb
|
|
5379
|
-
}]).pipe(delay(
|
|
5375
|
+
}]).pipe(delay(0));
|
|
5380
5376
|
}
|
|
5381
5377
|
else {
|
|
5382
5378
|
this._scrollSize.set(actualScrollSize);
|