ng-virtual-list 20.10.17 → 20.10.18
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 -42
- package/fesm2022/ng-virtual-list.mjs.map +1 -1
- package/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -4222,6 +4222,9 @@ class NgScrollerComponent extends NgScrollView {
|
|
|
4222
4222
|
onScrollBarDragHandler(event) {
|
|
4223
4223
|
const { position, min, max, userAction } = event;
|
|
4224
4224
|
this._isScrollbarUserAction = userAction;
|
|
4225
|
+
if (!userAction) {
|
|
4226
|
+
return;
|
|
4227
|
+
}
|
|
4225
4228
|
this._$scrollbarScroll.next(userAction);
|
|
4226
4229
|
this.stopScrolling();
|
|
4227
4230
|
const isVertical = this.isVertical(), { position: absolutePosition, } = this._scrollBox.getScrollPositionByScrollBar({
|
|
@@ -4236,10 +4239,13 @@ class NgScrollerComponent extends NgScrollView {
|
|
|
4236
4239
|
this.fireUpdateIfEdgesDetected(position, min, max, true, true);
|
|
4237
4240
|
}
|
|
4238
4241
|
onScrollBarDragEndHandler(event) {
|
|
4239
|
-
const { position, min, max } = event;
|
|
4242
|
+
const { position, min, max, userAction } = event;
|
|
4240
4243
|
this._isScrollbarUserAction = false;
|
|
4241
4244
|
this._velocities = [0];
|
|
4242
4245
|
this._velocity = 0;
|
|
4246
|
+
if (!userAction) {
|
|
4247
|
+
return;
|
|
4248
|
+
}
|
|
4243
4249
|
this.refresh(true, true);
|
|
4244
4250
|
this.fireUpdateIfEdgesDetected(position, min, max, true, true);
|
|
4245
4251
|
this._$scrollbarScroll.next(false);
|
|
@@ -6082,13 +6088,13 @@ class NgVirtualListComponent {
|
|
|
6082
6088
|
this.listenCacheChangesIfNeed(dynamicSize);
|
|
6083
6089
|
})).subscribe();
|
|
6084
6090
|
const $preventScrollSnapping = this.$preventScrollSnapping;
|
|
6085
|
-
$preventScrollSnapping.pipe(takeUntilDestroyed(), filter$1(v => !!v), tap((
|
|
6091
|
+
$preventScrollSnapping.pipe(takeUntilDestroyed(), filter$1(v => !!v), tap(() => {
|
|
6086
6092
|
if (this._readyForShow) {
|
|
6087
6093
|
this._trackBox.isScrollStart = this._trackBox.isScrollEnd = false;
|
|
6088
6094
|
this._isScrollStart.set(false);
|
|
6089
6095
|
this._isScrollEnd.set(false);
|
|
6090
6096
|
const scroller = this._scrollerComponent();
|
|
6091
|
-
if (scroller) {
|
|
6097
|
+
if (!!scroller) {
|
|
6092
6098
|
this._trackBox.preventScrollSnapping(true);
|
|
6093
6099
|
}
|
|
6094
6100
|
}
|
|
@@ -6126,19 +6132,19 @@ class NgVirtualListComponent {
|
|
|
6126
6132
|
const isVertical = this.isVertical, maxScrollSize = Math.round(isVertical ? scroller.scrollHeight ?? 0 : scroller.scrollWidth ?? 0), scrollSize = isVertical ? scroller.scrollTop ?? 0 : scroller.scrollLeft ?? 0, actualScrollSize = Math.round(scrollSize + delta);
|
|
6127
6133
|
if (this._readyForShow && !isLoading) {
|
|
6128
6134
|
if (maxScrollSize >= 0) {
|
|
6129
|
-
const isScrollStart = actualScrollSize <= MIN_PIXELS_FOR_PREVENT_SNAPPING;
|
|
6135
|
+
const isScrollStart = (actualScrollSize <= MIN_PIXELS_FOR_PREVENT_SNAPPING);
|
|
6130
6136
|
if (isScrollStart) {
|
|
6131
|
-
this._trackBox.isScrollStart = true;
|
|
6132
6137
|
this._isScrollStart.set(true);
|
|
6133
|
-
this._trackBox.isScrollEnd = false;
|
|
6134
6138
|
this._isScrollEnd.set(false);
|
|
6139
|
+
this._trackBox.isScrollStart = true;
|
|
6140
|
+
this._trackBox.isScrollEnd = false;
|
|
6135
6141
|
}
|
|
6136
6142
|
else {
|
|
6137
|
-
const isScrollEnd = actualScrollSize >= (maxScrollSize - MIN_PIXELS_FOR_PREVENT_SNAPPING);
|
|
6138
|
-
this._trackBox.isScrollStart = false;
|
|
6143
|
+
const isScrollEnd = (actualScrollSize >= (maxScrollSize - MIN_PIXELS_FOR_PREVENT_SNAPPING));
|
|
6139
6144
|
this._isScrollStart.set(false);
|
|
6140
|
-
this._trackBox.isScrollEnd = isScrollEnd;
|
|
6141
6145
|
this._isScrollEnd.set(isScrollEnd);
|
|
6146
|
+
this._trackBox.isScrollStart = false;
|
|
6147
|
+
this._trackBox.isScrollEnd = isScrollEnd;
|
|
6142
6148
|
}
|
|
6143
6149
|
}
|
|
6144
6150
|
}
|
|
@@ -6199,10 +6205,9 @@ class NgVirtualListComponent {
|
|
|
6199
6205
|
}
|
|
6200
6206
|
return;
|
|
6201
6207
|
}
|
|
6202
|
-
if ((snapScrollToEnd && this._trackBox.isSnappedToEnd) ||
|
|
6203
|
-
(
|
|
6204
|
-
|
|
6205
|
-
(scrollPositionAfterUpdate + MIN_PIXELS_FOR_PREVENT_SNAPPING >= roundedMaxPositionAfterUpdate)))) {
|
|
6208
|
+
if ((snapScrollToEnd && this._trackBox.isSnappedToEnd) || (!snapScrollToStart && snapScrollToEnd && !scroller.scrollable) ||
|
|
6209
|
+
(scrollPositionAfterUpdate + MIN_PIXELS_FOR_PREVENT_SNAPPING >= roundedMaxPositionAfterUpdate) ||
|
|
6210
|
+
(roundedScrollPositionAfterUpdate >= scrollPositionAfterUpdate + MIN_PIXELS_FOR_PREVENT_SNAPPING)) {
|
|
6206
6211
|
this._trackBox.clearDelta();
|
|
6207
6212
|
if (!this._trackBox.isSnappedToEnd) {
|
|
6208
6213
|
this._trackBox.isScrollStart = false;
|
|
@@ -6666,17 +6671,13 @@ class NgVirtualListComponent {
|
|
|
6666
6671
|
validateIteration(iteration);
|
|
6667
6672
|
const actualIteration = validateScrollIteration(iteration);
|
|
6668
6673
|
this._elementRef.nativeElement.focus();
|
|
6674
|
+
if (!this._scrollerComponent()?.scrollable) {
|
|
6675
|
+
this.scrollToFinalize(id, focused, cb);
|
|
6676
|
+
return;
|
|
6677
|
+
}
|
|
6669
6678
|
this._$scrollTo.next({
|
|
6670
6679
|
id, behavior, blending, iteration: actualIteration, isLastIteration: actualIteration === MAX_SCROLL_TO_ITERATIONS, cb: () => {
|
|
6671
|
-
|
|
6672
|
-
const el = this.getFocusedElementById(id);
|
|
6673
|
-
if (!!el) {
|
|
6674
|
-
this._service.focus(el, FocusAlignments.NONE);
|
|
6675
|
-
}
|
|
6676
|
-
}
|
|
6677
|
-
if (typeof cb === 'function') {
|
|
6678
|
-
cb?.();
|
|
6679
|
-
}
|
|
6680
|
+
this.scrollToFinalize(id, focused, cb);
|
|
6680
6681
|
}
|
|
6681
6682
|
});
|
|
6682
6683
|
}
|
|
@@ -6691,8 +6692,8 @@ class NgVirtualListComponent {
|
|
|
6691
6692
|
const behavior = options?.behavior ?? BEHAVIOR_INSTANT, blending = options?.blending ?? false, focused = options?.focused ?? true, iteration = options?.iteration ?? 0;
|
|
6692
6693
|
validateScrollBehavior(behavior);
|
|
6693
6694
|
validateIteration(iteration);
|
|
6694
|
-
const trackBy = this.trackBy(), items = this.items(),
|
|
6695
|
-
if (!!
|
|
6695
|
+
const trackBy = this.trackBy(), items = this.items(), firstItem = items.length > 0 ? items[0] ?? null : null, id = firstItem?.[trackBy] ?? null, actualIteration = validateScrollIteration(iteration);
|
|
6696
|
+
if (!!firstItem) {
|
|
6696
6697
|
this._elementRef.nativeElement.focus();
|
|
6697
6698
|
this._$scrollTo.next({
|
|
6698
6699
|
id, behavior, blending, iteration: actualIteration, isLastIteration: actualIteration === MAX_SCROLL_TO_ITERATIONS, cb: () => {
|
|
@@ -6700,15 +6701,7 @@ class NgVirtualListComponent {
|
|
|
6700
6701
|
this._trackBox.isScrollStart = true;
|
|
6701
6702
|
this._trackBox.isScrollEnd = false;
|
|
6702
6703
|
this._$fireUpdate.next(true);
|
|
6703
|
-
|
|
6704
|
-
const el = this.getFocusedElementById(id);
|
|
6705
|
-
if (!!el) {
|
|
6706
|
-
this._service.focus(el, FocusAlignments.NONE);
|
|
6707
|
-
}
|
|
6708
|
-
}
|
|
6709
|
-
if (typeof cb === 'function') {
|
|
6710
|
-
cb?.();
|
|
6711
|
-
}
|
|
6704
|
+
this.scrollToFinalize(id, focused, cb);
|
|
6712
6705
|
}
|
|
6713
6706
|
});
|
|
6714
6707
|
}
|
|
@@ -6733,24 +6726,31 @@ class NgVirtualListComponent {
|
|
|
6733
6726
|
validateIteration(iteration);
|
|
6734
6727
|
const trackBy = this.trackBy(), items = this.items(), latItem = items[items.length > 0 ? items.length - 1 : 0], id = latItem[trackBy], actualIteration = validateScrollIteration(iteration);
|
|
6735
6728
|
this._elementRef.nativeElement.focus();
|
|
6729
|
+
if (!this._scrollerComponent()?.scrollable) {
|
|
6730
|
+
this.scrollToFinalize(id, focused, cb);
|
|
6731
|
+
return;
|
|
6732
|
+
}
|
|
6736
6733
|
this._$scrollTo.next({
|
|
6737
6734
|
id, behavior, blending, iteration: actualIteration, isLastIteration: actualIteration === MAX_SCROLL_TO_ITERATIONS, cb: () => {
|
|
6738
6735
|
this._isScrollEnd.set(true);
|
|
6739
6736
|
this._trackBox.isScrollStart = false;
|
|
6740
6737
|
this._trackBox.isScrollEnd = true;
|
|
6741
6738
|
this._$fireUpdate.next(true);
|
|
6742
|
-
|
|
6743
|
-
const el = this.getFocusedElementById(id);
|
|
6744
|
-
if (!!el) {
|
|
6745
|
-
this._service.focus(el, FocusAlignments.NONE);
|
|
6746
|
-
}
|
|
6747
|
-
}
|
|
6748
|
-
if (typeof cb === 'function') {
|
|
6749
|
-
cb?.();
|
|
6750
|
-
}
|
|
6739
|
+
this.scrollToFinalize(id, focused, cb);
|
|
6751
6740
|
}
|
|
6752
6741
|
});
|
|
6753
6742
|
}
|
|
6743
|
+
scrollToFinalize(id, focused, cb) {
|
|
6744
|
+
if (focused) {
|
|
6745
|
+
const el = this.getFocusedElementById(id);
|
|
6746
|
+
if (!!el) {
|
|
6747
|
+
this._service.focus(el, FocusAlignments.NONE);
|
|
6748
|
+
}
|
|
6749
|
+
}
|
|
6750
|
+
if (typeof cb === 'function') {
|
|
6751
|
+
cb?.();
|
|
6752
|
+
}
|
|
6753
|
+
}
|
|
6754
6754
|
cleanup() {
|
|
6755
6755
|
const displayItems = [];
|
|
6756
6756
|
this._service.collection = displayItems;
|