ng-virtual-list 20.10.6 → 20.10.7
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 +0 -13
- package/fesm2022/ng-virtual-list.mjs +30 -24
- package/fesm2022/ng-virtual-list.mjs.map +1 -1
- package/index.d.ts +4 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -732,19 +732,6 @@ Properties
|
|
|
732
732
|
|
|
733
733
|
<br/>
|
|
734
734
|
|
|
735
|
-
## 📦 Previous versions
|
|
736
|
-
|
|
737
|
-
| Angular version | ng-virtual-list version | git | npm |
|
|
738
|
-
|--|--|--|--|
|
|
739
|
-
| 19.x | 19.10.1 | [19.x](https://github.com/DjonnyX/ng-virtual-list/tree/19.x) | [19.10.1](https://www.npmjs.com/package/ng-virtual-list/v/19.10.1) |
|
|
740
|
-
| 18.x | 18.10.1 | [18.x](https://github.com/DjonnyX/ng-virtual-list/tree/18.x) | [18.10.1](https://www.npmjs.com/package/ng-virtual-list/v/18.10.1) |
|
|
741
|
-
| 17.x | 17.10.1 | [17.x](https://github.com/DjonnyX/ng-virtual-list/tree/17.x) | [17.10.1](https://www.npmjs.com/package/ng-virtual-list/v/17.10.1) |
|
|
742
|
-
| 16.x | 16.10.0 | [16.x](https://github.com/DjonnyX/ng-virtual-list/tree/16.x) | [16.10.0](https://www.npmjs.com/package/ng-virtual-list/v/16.10.0) |
|
|
743
|
-
| 15.x | 15.10.0 | [15.x](https://github.com/DjonnyX/ng-virtual-list/tree/15.x) | [15.10.0](https://www.npmjs.com/package/ng-virtual-list/v/15.10.0) |
|
|
744
|
-
| 14.x | 14.10.1 | [14.x](https://github.com/DjonnyX/ng-virtual-list/tree/14.x) | [14.10.1](https://www.npmjs.com/package/ng-virtual-list/v/14.10.1) |
|
|
745
|
-
|
|
746
|
-
<br/>
|
|
747
|
-
|
|
748
735
|
## 🤝 Contributing
|
|
749
736
|
|
|
750
737
|
PRs and feature requests are welcome!
|
|
@@ -3099,6 +3099,9 @@ class NgScrollView {
|
|
|
3099
3099
|
}
|
|
3100
3100
|
_destroyRef = inject(DestroyRef);
|
|
3101
3101
|
_isMoving = false;
|
|
3102
|
+
get isMoving() {
|
|
3103
|
+
return this._isMoving;
|
|
3104
|
+
}
|
|
3102
3105
|
_x = 0;
|
|
3103
3106
|
set x(v) {
|
|
3104
3107
|
this._x = this._actualX = v;
|
|
@@ -3113,7 +3116,7 @@ class NgScrollView {
|
|
|
3113
3116
|
set totalSize(v) {
|
|
3114
3117
|
this._totalSize = v;
|
|
3115
3118
|
}
|
|
3116
|
-
|
|
3119
|
+
_startPosition = this._totalSize;
|
|
3117
3120
|
get actualScrollHeight() {
|
|
3118
3121
|
const { height: viewportHeight } = this.viewportBounds(), totalSize = this._totalSize;
|
|
3119
3122
|
if (this._inversion) {
|
|
@@ -3177,6 +3180,9 @@ class NgScrollView {
|
|
|
3177
3180
|
_interactive = true;
|
|
3178
3181
|
_inversion = inject(SCROLL_VIEW_INVERSION);
|
|
3179
3182
|
_overscrollIteration = 0;
|
|
3183
|
+
set delta(v) {
|
|
3184
|
+
this._startPosition += v;
|
|
3185
|
+
}
|
|
3180
3186
|
constructor() {
|
|
3181
3187
|
this._viewportResizeObserver = new ResizeObserver(this._onResizeViewportHandler);
|
|
3182
3188
|
this._contentResizeObserver = new ResizeObserver(this._onResizeContentHandler);
|
|
@@ -3215,21 +3221,17 @@ class NgScrollView {
|
|
|
3215
3221
|
if (target.classList.contains(INTERACTIVE)) {
|
|
3216
3222
|
return of(undefined);
|
|
3217
3223
|
}
|
|
3218
|
-
this._prevTotalSize = this._totalSize;
|
|
3219
3224
|
const inversion = this._inversion, isVertical = this.isVertical();
|
|
3220
3225
|
this._isMoving = true;
|
|
3221
3226
|
this.grabbing.set(true);
|
|
3222
|
-
|
|
3227
|
+
this._startPosition = (isVertical ? this.y : this.x);
|
|
3223
3228
|
let prevClientPosition = 0, startClientPos = isVertical ? e.clientY : e.clientX, offsets = new Array(), velocities = new Array(), startTime = Date.now();
|
|
3224
3229
|
return fromEvent(window, MOUSE_MOVE, { passive: false }).pipe(takeUntilDestroyed(this._destroyRef), takeUntil$1($mouseDragCancel), tap(e => {
|
|
3225
3230
|
this.checkOverscroll(e);
|
|
3226
3231
|
}), switchMap$1(e => {
|
|
3227
|
-
|
|
3228
|
-
this._prevTotalSize = this._totalSize;
|
|
3229
|
-
const currentPos = (isVertical ? e.clientY : e.clientX), scrollSize = isVertical ? this.scrollHeight : this.scrollWidth, delta = (inversion ? -1 : 1) * (startClientPos - currentPos), dp = startPos + delta, position = Math.round(dp < 0 ? 0 : dp > scrollSize ? scrollSize : dp), endTime = Date.now(), timestamp = endTime - startTime, scrollDelta = prevClientPosition === 0 ? 0 : prevClientPosition - currentPos, { v0 } = this.calculateVelocity(offsets, scrollDelta, timestamp);
|
|
3230
|
-
this.calculateAcceleration(velocities, v0, timestamp);
|
|
3232
|
+
const { position, currentPos, endTime, scrollDelta } = this.calculatePosition(isVertical, e, inversion, startClientPos, startTime, prevClientPosition, offsets, velocities);
|
|
3231
3233
|
prevClientPosition = currentPos;
|
|
3232
|
-
this.move(isVertical, position,
|
|
3234
|
+
this.move(isVertical, position, true, true, true);
|
|
3233
3235
|
startTime = endTime;
|
|
3234
3236
|
return race([fromEvent(window, MOUSE_UP, { passive: false }), fromEvent(content, MOUSE_UP, { passive: false })]).pipe(takeUntilDestroyed(this._destroyRef), tap(e => {
|
|
3235
3237
|
this.cancelOverscroll();
|
|
@@ -3257,21 +3259,17 @@ class NgScrollView {
|
|
|
3257
3259
|
if (target.classList.contains(INTERACTIVE)) {
|
|
3258
3260
|
return of(undefined);
|
|
3259
3261
|
}
|
|
3260
|
-
this._prevTotalSize = this._totalSize;
|
|
3261
3262
|
const inversion = this._inversion, isVertical = this.isVertical();
|
|
3262
3263
|
this._isMoving = true;
|
|
3263
3264
|
this.grabbing.set(true);
|
|
3264
|
-
|
|
3265
|
-
let prevClientPosition = 0, startClientPos = isVertical ? e.touches[e.touches.length - 1].clientY : e.touches[e.touches.length - 1].clientX, offsets = new Array(), velocities = new Array(), startTime = Date.now()
|
|
3265
|
+
this._startPosition = (isVertical ? this.y : this.x);
|
|
3266
|
+
let prevClientPosition = 0, startClientPos = isVertical ? e.touches[e.touches.length - 1].clientY : e.touches[e.touches.length - 1].clientX, offsets = new Array(), velocities = new Array(), startTime = Date.now();
|
|
3266
3267
|
return fromEvent(window, TOUCH_MOVE, { passive: false }).pipe(takeUntilDestroyed(this._destroyRef), takeUntil$1($touchCanceler), tap(e => {
|
|
3267
3268
|
this.checkOverscroll(e);
|
|
3268
3269
|
}), switchMap$1(e => {
|
|
3269
|
-
|
|
3270
|
-
prevTotalSize = this._totalSize;
|
|
3271
|
-
const currentPos = isVertical ? e.touches[e.touches.length - 1].clientY : e.touches[e.touches.length - 1].clientX, scrollSize = isVertical ? this.scrollHeight : this.scrollWidth, delta = (inversion ? -1 : 1) * (startClientPos - currentPos), dp = startPos + delta, position = Math.round(dp < 0 ? 0 : dp > scrollSize ? scrollSize : dp), endTime = Date.now(), timestamp = endTime - startTime, scrollDelta = prevClientPosition === 0 ? 0 : prevClientPosition - currentPos, { v0 } = this.calculateVelocity(offsets, scrollDelta, timestamp);
|
|
3272
|
-
this.calculateAcceleration(velocities, v0, timestamp);
|
|
3270
|
+
const { position, currentPos, endTime, scrollDelta } = this.calculatePosition(isVertical, e, inversion, startClientPos, startTime, prevClientPosition, offsets, velocities);
|
|
3273
3271
|
prevClientPosition = currentPos;
|
|
3274
|
-
this.move(isVertical, position,
|
|
3272
|
+
this.move(isVertical, position, true, true, true);
|
|
3275
3273
|
startTime = endTime;
|
|
3276
3274
|
return race([fromEvent(window, TOUCH_END, { passive: false }), fromEvent(content, TOUCH_END, { passive: false })]).pipe(takeUntilDestroyed(this._destroyRef), tap(e => {
|
|
3277
3275
|
this.cancelOverscroll();
|
|
@@ -3287,6 +3285,14 @@ class NgScrollView {
|
|
|
3287
3285
|
}));
|
|
3288
3286
|
})).subscribe();
|
|
3289
3287
|
}
|
|
3288
|
+
calculatePosition(isVertical, e, inversion, startClientPos, startTime, prevClientPosition, offsets, velocities) {
|
|
3289
|
+
const currentPos = isVertical ? e.touches?.[e.touches?.length - 1]?.clientY || e.clientY : e.touches?.[e.touches?.length - 1]?.clientX || e.clientX, scrollSize = isVertical ? this.scrollHeight : this.scrollWidth, delta = (inversion ? -1 : 1) * (startClientPos - currentPos), dp = this._startPosition + delta, position = Math.round(dp < 0 ? 0 : dp > scrollSize ? scrollSize : dp), endTime = Date.now(), timestamp = endTime - startTime, scrollDelta = prevClientPosition === 0 ? 0 : prevClientPosition - currentPos, { v0 } = this.calculateVelocity(offsets, scrollDelta, timestamp);
|
|
3290
|
+
this.calculateAcceleration(velocities, v0, timestamp);
|
|
3291
|
+
prevClientPosition = currentPos;
|
|
3292
|
+
this.move(isVertical, position, true, true, true);
|
|
3293
|
+
startTime = endTime;
|
|
3294
|
+
return { position, currentPos, endTime, scrollDelta };
|
|
3295
|
+
}
|
|
3290
3296
|
cancelOverscroll() {
|
|
3291
3297
|
if (!this.overscrollEnabled()) {
|
|
3292
3298
|
return;
|
|
@@ -3370,7 +3376,6 @@ class NgScrollView {
|
|
|
3370
3376
|
}
|
|
3371
3377
|
move(isVertical, position, blending = false, userAction = false, fireUpdate = true) {
|
|
3372
3378
|
this.scroll({ [isVertical ? TOP$1 : LEFT$1]: position, behavior: INSTANT$1, blending, userAction, fireUpdate });
|
|
3373
|
-
this._prevTotalSize = this._totalSize;
|
|
3374
3379
|
}
|
|
3375
3380
|
moveWithAcceleration(isVertical, position, v0, v, a0) {
|
|
3376
3381
|
if (a0 !== 0) {
|
|
@@ -5137,6 +5142,7 @@ class NgVirtualListComponent {
|
|
|
5137
5142
|
if (this._isSnappingMethodAdvanced) {
|
|
5138
5143
|
this.updateRegularRenderer();
|
|
5139
5144
|
}
|
|
5145
|
+
scroller.delta = delta;
|
|
5140
5146
|
this._trackBox.clearDelta();
|
|
5141
5147
|
if ((snapScrollToBottom && this._trackBox.isSnappedToEnd) ||
|
|
5142
5148
|
(snapScrollToBottom && actualScrollSize > 0 &&
|
|
@@ -5154,7 +5160,7 @@ class NgVirtualListComponent {
|
|
|
5154
5160
|
const params = {
|
|
5155
5161
|
[isVertical ? TOP_PROP_NAME : LEFT_PROP_NAME]: roundedMaxPositionAfterUpdate,
|
|
5156
5162
|
fireUpdate: false, behavior: BEHAVIOR_INSTANT,
|
|
5157
|
-
blending:
|
|
5163
|
+
blending: scroller.isMoving, duration: this.animationParams().scrollToItem,
|
|
5158
5164
|
};
|
|
5159
5165
|
scroller?.scrollTo?.(params);
|
|
5160
5166
|
this._$update.next(this.getScrollStateVersion(totalSize, this._isVertical ? scroller.scrollTop : scroller.scrollLeft, cacheVersion));
|
|
@@ -5313,7 +5319,7 @@ class NgVirtualListComponent {
|
|
|
5313
5319
|
if (items && items.length) {
|
|
5314
5320
|
const dynamicSize = this.dynamicSize(), itemSize = this.itemSize();
|
|
5315
5321
|
if (dynamicSize) {
|
|
5316
|
-
const { width, height, x, y } = this._bounds() || { x: 0, y: 0, width: DEFAULT_LIST_SIZE, height: DEFAULT_LIST_SIZE }, itemConfigMap = this.itemConfigMap(), items = this._actualItems(), isVertical = this._isVertical,
|
|
5322
|
+
const { width, height, x, y } = this._bounds() || { x: 0, y: 0, width: DEFAULT_LIST_SIZE, height: DEFAULT_LIST_SIZE }, itemConfigMap = this.itemConfigMap(), items = this._actualItems(), isVertical = this._isVertical, currentScrollSize = (isVertical ? scrollerComponent.scrollTop : scrollerComponent.scrollLeft), delta = this._trackBox.delta, opts = {
|
|
5317
5323
|
bounds: { width, height, x, y }, collection: items, dynamicSize, isVertical: this._isVertical, itemSize,
|
|
5318
5324
|
bufferSize: this.bufferSize(), maxBufferSize: this.maxBufferSize(),
|
|
5319
5325
|
scrollSize: (isVertical ? scrollerComponent.scrollTop : scrollerComponent.scrollLeft) + delta,
|
|
@@ -5341,7 +5347,7 @@ class NgVirtualListComponent {
|
|
|
5341
5347
|
return of([true, { id, blending, scroller: scrollerComponent, scrollCalled, cb }]);
|
|
5342
5348
|
}
|
|
5343
5349
|
this._$snapScrollToEndCanceller.next(true);
|
|
5344
|
-
const notChanged = actualScrollSize ===
|
|
5350
|
+
const notChanged = actualScrollSize === currentScrollSize;
|
|
5345
5351
|
scrollerComponent?.scrollTo?.(params);
|
|
5346
5352
|
if ((!notChanged && iteration < MAX_SCROLL_TO_ITERATIONS) || iteration < MAX_SCROLL_TO_ITERATIONS) {
|
|
5347
5353
|
this._$scrollTo.next(params);
|
|
@@ -5358,8 +5364,8 @@ class NgVirtualListComponent {
|
|
|
5358
5364
|
else {
|
|
5359
5365
|
const index = items.findIndex(item => item[trackBy] === id);
|
|
5360
5366
|
if (index > -1) {
|
|
5361
|
-
const isVertical = this._isVertical,
|
|
5362
|
-
if (
|
|
5367
|
+
const isVertical = this._isVertical, currentScrollSize = (isVertical ? scrollerComponent.scrollTop : scrollerComponent.scrollLeft), scrollSize = index * this.itemSize();
|
|
5368
|
+
if (currentScrollSize !== scrollSize) {
|
|
5363
5369
|
this._$snapScrollToEndCanceller.next(true);
|
|
5364
5370
|
const params = {
|
|
5365
5371
|
[this._isVertical ? TOP_PROP_NAME : LEFT_PROP_NAME]: scrollSize,
|
|
@@ -5457,8 +5463,8 @@ class NgVirtualListComponent {
|
|
|
5457
5463
|
emitScrollEvent(isScrollEnd = false, update = true) {
|
|
5458
5464
|
const scrollerEl = this._scroller()?.nativeElement, scrollerComponent = this._scrollerComponent();
|
|
5459
5465
|
if (scrollerEl && scrollerComponent) {
|
|
5460
|
-
const isVertical = this._isVertical, scrollSize = (isVertical ? scrollerComponent.scrollTop : scrollerComponent.scrollLeft), bounds = this._bounds() || { x: 0, y: 0, width: DEFAULT_LIST_SIZE, height: DEFAULT_LIST_SIZE },
|
|
5461
|
-
this._trackBox.deltaDirection =
|
|
5466
|
+
const isVertical = this._isVertical, scrollSize = (isVertical ? scrollerComponent.scrollTop : scrollerComponent.scrollLeft), bounds = this._bounds() || { x: 0, y: 0, width: DEFAULT_LIST_SIZE, height: DEFAULT_LIST_SIZE }, currentScrollSize = this._scrollSize();
|
|
5467
|
+
this._trackBox.deltaDirection = currentScrollSize > scrollSize ? -1 : currentScrollSize < scrollSize ? 1 : 0;
|
|
5462
5468
|
const itemsRange = formatActualDisplayItems(this._service.displayItems, this.scrollStartOffset(), this.scrollEndOffset(), scrollSize, isVertical, bounds), event = new ScrollEvent({
|
|
5463
5469
|
direction: this._trackBox.scrollDirection, container: scrollerEl,
|
|
5464
5470
|
list: this._list().nativeElement, delta: this._trackBox.delta,
|