ng-virtual-list 22.12.8 → 22.12.9
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 +8 -8
- package/fesm2022/ng-virtual-list.mjs +116 -29
- package/fesm2022/ng-virtual-list.mjs.map +1 -1
- package/package.json +1 -1
- package/types/ng-virtual-list.d.ts +8 -1
package/README.md
CHANGED
|
@@ -732,14 +732,14 @@ import { NgVirtualListModule, VirtualClickModule } from 'ng-virtual-list';
|
|
|
732
732
|
|
|
733
733
|
| Angular version | ng-virtual-list version | git | npm |
|
|
734
734
|
|--|--|--|--|
|
|
735
|
-
| 21.x | 21.12.
|
|
736
|
-
| 20.x | 20.12.
|
|
737
|
-
| 19.x | 19.12.
|
|
738
|
-
| 18.x | 18.12.
|
|
739
|
-
| 17.x | 17.12.
|
|
740
|
-
| 16.x | 16.12.
|
|
741
|
-
| 15.x | 15.12.
|
|
742
|
-
| 14.x | 14.12.
|
|
735
|
+
| 21.x | 21.12.9 | [20.x](https://github.com/DjonnyX/ng-virtual-list/tree/21.x) | [21.12.9](https://www.npmjs.com/package/ng-virtual-list/v/21.12.9) |
|
|
736
|
+
| 20.x | 20.12.9 | [20.x](https://github.com/DjonnyX/ng-virtual-list/tree/20.x) | [20.12.9](https://www.npmjs.com/package/ng-virtual-list/v/20.12.9) |
|
|
737
|
+
| 19.x | 19.12.9 | [19.x](https://github.com/DjonnyX/ng-virtual-list/tree/19.x) | [19.12.9](https://www.npmjs.com/package/ng-virtual-list/v/19.12.9) |
|
|
738
|
+
| 18.x | 18.12.9 | [18.x](https://github.com/DjonnyX/ng-virtual-list/tree/18.x) | [18.12.9](https://www.npmjs.com/package/ng-virtual-list/v/18.12.9) |
|
|
739
|
+
| 17.x | 17.12.9 | [17.x](https://github.com/DjonnyX/ng-virtual-list/tree/17.x) | [17.12.9](https://www.npmjs.com/package/ng-virtual-list/v/17.12.9) |
|
|
740
|
+
| 16.x | 16.12.9 | [16.x](https://github.com/DjonnyX/ng-virtual-list/tree/16.x) | [16.12.9](https://www.npmjs.com/package/ng-virtual-list/v/16.12.9) |
|
|
741
|
+
| 15.x | 15.12.9 | [15.x](https://github.com/DjonnyX/ng-virtual-list/tree/15.x) | [15.12.9](https://www.npmjs.com/package/ng-virtual-list/v/15.12.9) |
|
|
742
|
+
| 14.x | 14.12.9 | [14.x](https://github.com/DjonnyX/ng-virtual-list/tree/14.x) | [14.12.9](https://www.npmjs.com/package/ng-virtual-list/v/14.12.9) |
|
|
743
743
|
|
|
744
744
|
<br/>
|
|
745
745
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { Injectable, inject, viewChild, signal, ElementRef, DestroyRef, effect, computed, ChangeDetectionStrategy, Component, output, Input, Directive, Injector, InjectionToken, input, ViewChild, ViewContainerRef, ViewEncapsulation, NO_ERRORS_SCHEMA, NgModule } from '@angular/core';
|
|
3
|
-
import { Subject, BehaviorSubject, distinctUntilChanged, combineLatest, tap, map, fromEvent, race, of, debounceTime, switchMap as switchMap$1, filter as filter$1, delay, takeUntil as takeUntil$1, startWith,
|
|
3
|
+
import { Subject, BehaviorSubject, distinctUntilChanged, combineLatest, tap, map, fromEvent, race, of, debounceTime, switchMap as switchMap$1, filter as filter$1, delay, takeUntil as takeUntil$1, startWith, take, from, skip } from 'rxjs';
|
|
4
4
|
import { takeUntilDestroyed, toSignal, toObservable } from '@angular/core/rxjs-interop';
|
|
5
5
|
import { BehaviorSubject as BehaviorSubject$1 } from 'rxjs/internal/BehaviorSubject';
|
|
6
6
|
import * as i1 from '@angular/common';
|
|
@@ -4168,7 +4168,7 @@ class Animator {
|
|
|
4168
4168
|
const SCROLL_VIEW_INVERSION = new InjectionToken('ScrollViewInversion');
|
|
4169
4169
|
const SCROLL_VIEW_OVERSCROLL_ENABLED = new InjectionToken('ScrollViewOverscrollEnabled');
|
|
4170
4170
|
const SCROLL_VIEW_NORMALIZE_VALUE_FROM_ZERO = new InjectionToken('ScrollViewNormalizeValueFromZero');
|
|
4171
|
-
const TOP$1 = 'top', LEFT$2 = 'left', INSTANT$1 = 'instant', AUTO = 'auto', SMOOTH = 'smooth', DURATION = 2000, FRICTION_FORCE = .035, MAX_DURATION = 4000, ANIMATION_DURATION = 50, MASS = .005, ACCELERATION_SCALE = 40, MAX_DIST = 12500, MAX_VELOCITY_TIMESTAMP = 100, SPEED_SCALE = 15, OVERSCROLL_START_ITERATION = 2;
|
|
4171
|
+
const TOP$1 = 'top', LEFT$2 = 'left', INSTANT$1 = 'instant', AUTO = 'auto', SMOOTH = 'smooth', DURATION = 2000, FRICTION_FORCE = .035, MAX_DURATION = 4000, ANIMATION_DURATION = 50, MASS = .005, ACCELERATION_SCALE = 40, MAX_DIST = 12500, MIN_DELTA = 0.1, MAX_VELOCITY_TIMESTAMP = 100, MAX_VELOCITIES_LENGTH = 10, MIN_ACCELERATION = 0.001, SPEED_SCALE = 15, OVERSCROLL_START_ITERATION = 2;
|
|
4172
4172
|
const MAX_ITERATIONS_FOR_AVERAGE_CALCULATIONS = 5, INSTANT_VELOCITY_SCALE = 1000;
|
|
4173
4173
|
const SCROLL_EVENT$1 = new Event(SCROLLER_SCROLL);
|
|
4174
4174
|
|
|
@@ -4563,12 +4563,32 @@ class NgScrollView extends BaseScrollView {
|
|
|
4563
4563
|
get averageVelocity() { return this._$averageVelocity.getValue(); }
|
|
4564
4564
|
_measureVelocityTimestamp = Date.now();
|
|
4565
4565
|
_measureVelocityLastPosition = this.isVertical() ? this._y : this._x;
|
|
4566
|
-
|
|
4566
|
+
_startPositionX = 0;
|
|
4567
|
+
_startPositionY = 0;
|
|
4568
|
+
set startPosition(v) {
|
|
4569
|
+
const isVertical = this.isVertical(), c = isVertical ? this._startPositionY : this._startPositionX;
|
|
4570
|
+
if (v !== c) {
|
|
4571
|
+
if (isVertical) {
|
|
4572
|
+
this._startPositionY = v;
|
|
4573
|
+
}
|
|
4574
|
+
else {
|
|
4575
|
+
this._startPositionX = v;
|
|
4576
|
+
}
|
|
4577
|
+
}
|
|
4578
|
+
}
|
|
4579
|
+
get startPosition() {
|
|
4580
|
+
if (this.isVertical()) {
|
|
4581
|
+
return this._startPositionY;
|
|
4582
|
+
}
|
|
4583
|
+
return this._startPositionX;
|
|
4584
|
+
}
|
|
4567
4585
|
_animator = new Animator();
|
|
4568
4586
|
_interactive = true;
|
|
4569
4587
|
_horizontalAxisInvertion;
|
|
4570
4588
|
get inverted() { return this._horizontalAxisInvertion(); }
|
|
4571
4589
|
_overscrollIteration = 0;
|
|
4590
|
+
_overscrollStartIteration = 0;
|
|
4591
|
+
_overscrollApplied = false;
|
|
4572
4592
|
set x(v) {
|
|
4573
4593
|
this.setX(v);
|
|
4574
4594
|
}
|
|
@@ -4608,7 +4628,7 @@ class NgScrollView extends BaseScrollView {
|
|
|
4608
4628
|
_delta = 0;
|
|
4609
4629
|
set delta(v) {
|
|
4610
4630
|
this._delta = v;
|
|
4611
|
-
this.
|
|
4631
|
+
this.startPosition += v;
|
|
4612
4632
|
}
|
|
4613
4633
|
set startLayoutOffset(v) {
|
|
4614
4634
|
if (this._startLayoutOffset !== v) {
|
|
@@ -4617,6 +4637,8 @@ class NgScrollView extends BaseScrollView {
|
|
|
4617
4637
|
}
|
|
4618
4638
|
}
|
|
4619
4639
|
get startLayoutOffset() { return this._startLayoutOffset; }
|
|
4640
|
+
_scrollDirectionValueX = 0;
|
|
4641
|
+
_scrollDirectionValueY = 0;
|
|
4620
4642
|
_intersectionComponentId = null;
|
|
4621
4643
|
_isAlignmentAnimation = false;
|
|
4622
4644
|
get animated() { return this._animator?.isAnimated ?? false; }
|
|
@@ -4645,14 +4667,17 @@ class NgScrollView extends BaseScrollView {
|
|
|
4645
4667
|
const $wheel = this.$wheel;
|
|
4646
4668
|
$wheel.pipe(takeUntilDestroyed(), switchMap$1(v => of(this.averageVelocity)), debounceTime(100), tap(v => {
|
|
4647
4669
|
this.snapWithInitialForceIfNecessary(v);
|
|
4670
|
+
this._overscrollIteration = this._overscrollStartIteration = 0;
|
|
4671
|
+
this._overscrollApplied = false;
|
|
4648
4672
|
this._scrollDirection.clear();
|
|
4673
|
+
this._scrollDirectionValueX = this._scrollDirectionValueY = 0;
|
|
4649
4674
|
})).subscribe();
|
|
4650
4675
|
const $viewport = toObservable(this.scrollViewport).pipe(takeUntilDestroyed(this._destroyRef), filter$1(v => !!v), map(v => v.nativeElement)), $content = toObservable(this.scrollContent).pipe(takeUntilDestroyed(this._destroyRef), filter$1(v => !!v), map(v => v.nativeElement)), $wheelEmitter = this._inversion ? $viewport : $content;
|
|
4651
4676
|
$wheelEmitter.pipe(takeUntilDestroyed(this._destroyRef), switchMap$1(content => {
|
|
4652
4677
|
return fromEvent(content, WHEEL, { passive: false }).pipe(filter$1(() => this._interactive), takeUntilDestroyed(this._destroyRef), tap(e => {
|
|
4653
4678
|
const isVertical = this.isVertical();
|
|
4654
4679
|
this.emitScrollableEvent();
|
|
4655
|
-
this.checkOverscroll(e);
|
|
4680
|
+
this.checkOverscroll(e, true);
|
|
4656
4681
|
this.stopScrolling(true);
|
|
4657
4682
|
const scrollSize = isVertical ? this.scrollHeight : this.scrollWidth, startPos = isVertical ? this._y : this._x, delta = isVertical ? e.deltaY : (e.deltaX * (this._horizontalAxisInvertion() ? -1 : 1)), dp = (startPos + delta), position = this.isInfinity() ? dp : (dp < 0 ? 0 : dp > scrollSize ? scrollSize : dp);
|
|
4658
4683
|
this.scroll({ [isVertical ? TOP$1 : LEFT$2]: position, behavior: INSTANT$1, userAction: true, blending: false, fireUpdate: true });
|
|
@@ -4695,7 +4720,10 @@ class NgScrollView extends BaseScrollView {
|
|
|
4695
4720
|
$content.pipe(takeUntilDestroyed(this._destroyRef), switchMap$1(content => {
|
|
4696
4721
|
return fromEvent(content, MOUSE_DOWN, { passive: false }).pipe(takeUntilDestroyed(this._destroyRef), filter$1(v => this._interactive), switchMap$1(e => {
|
|
4697
4722
|
mouseCanceled = false;
|
|
4723
|
+
this._overscrollStartIteration = 0;
|
|
4724
|
+
this._overscrollApplied = false;
|
|
4698
4725
|
this._scrollDirection.clear();
|
|
4726
|
+
this._scrollDirectionValueX = this._scrollDirectionValueY = 0;
|
|
4699
4727
|
this.cancelOverscroll();
|
|
4700
4728
|
this.onDragStart();
|
|
4701
4729
|
this.stopScrolling(true);
|
|
@@ -4707,23 +4735,34 @@ class NgScrollView extends BaseScrollView {
|
|
|
4707
4735
|
const inversion = this._inversion, isVertical = this.isVertical();
|
|
4708
4736
|
this._isMoving = true;
|
|
4709
4737
|
this.grabbing.set(true);
|
|
4710
|
-
this.
|
|
4711
|
-
|
|
4738
|
+
this._startPositionX = this.x;
|
|
4739
|
+
this._startPositionY = this.y;
|
|
4740
|
+
let prevClientPositionX = (e.clientX) * (this._horizontalAxisInvertion() ? -1 : 1), prevClientPositionY = e.clientY, startClientPosX = prevClientPositionX, startClientPosY = prevClientPositionY, offsetsX = new Array(), offsetsY = new Array(), velocitiesX = new Array(), velocitiesY = new Array(), startTime = Date.now();
|
|
4712
4741
|
return fromEvent(window, MOUSE_MOVE, { passive: false }).pipe(takeUntilDestroyed(this._destroyRef), takeUntil$1($mouseDragCancel), tap(e => {
|
|
4713
4742
|
this.checkOverscroll(e);
|
|
4714
4743
|
}), switchMap$1(e => {
|
|
4715
|
-
const { position, currentPos, endTime, scrollDelta } = this.calculatePosition(
|
|
4716
|
-
|
|
4744
|
+
const { position: positionX, currentPos: currentPosX, endTime, scrollDelta: scrollDeltaX } = this.calculatePosition(false, true, this._horizontalAxisInvertion(), e, inversion, startClientPosX, startTime, prevClientPositionX, offsetsX, velocitiesX), { position: positionY, currentPos: currentPosY, scrollDelta: scrollDeltaY } = this.calculatePosition(true, true, false, e, inversion, startClientPosY, startTime, prevClientPositionY, offsetsY, velocitiesY), position = isVertical ? positionY : positionX;
|
|
4745
|
+
prevClientPositionX = currentPosX;
|
|
4746
|
+
prevClientPositionY = currentPosY;
|
|
4747
|
+
this._scrollDirectionValueX += Math.abs(scrollDeltaX);
|
|
4748
|
+
this._scrollDirectionValueY += Math.abs(scrollDeltaY);
|
|
4717
4749
|
this.move(isVertical, position, true, true, true);
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4750
|
+
if (this.isInfinity()) {
|
|
4751
|
+
const offset = Math.abs(position) - Math.abs(isVertical ? this._y : this._x), scrollSize = isVertical ? this.scrollHeight : this.scrollWidth, viewportSize = isVertical ? this.viewportBounds().height : this.viewportBounds().width;
|
|
4752
|
+
if (position >= (scrollSize - viewportSize * .5) || position <= 0) {
|
|
4753
|
+
if (isVertical) {
|
|
4754
|
+
startClientPosY -= offset;
|
|
4755
|
+
}
|
|
4756
|
+
else {
|
|
4757
|
+
startClientPosX -= offset;
|
|
4758
|
+
}
|
|
4759
|
+
}
|
|
4721
4760
|
}
|
|
4722
4761
|
startTime = endTime;
|
|
4723
4762
|
return race([fromEvent(window, MOUSE_UP, { passive: false }), fromEvent(content, MOUSE_UP, { passive: false })]).pipe(takeUntilDestroyed(this._destroyRef), takeUntil$1($mouseDragCancel), tap(e => {
|
|
4724
4763
|
mouseCanceled = true;
|
|
4725
4764
|
this.cancelOverscroll();
|
|
4726
|
-
const endTime = Date.now(), timestamp = endTime - startTime, { v0 } = this.calculateVelocity(
|
|
4765
|
+
const endTime = Date.now(), timestamp = endTime - startTime, { v0 } = this.calculateVelocity(isVertical ? offsetsY : offsetsX, isVertical ? scrollDeltaY : scrollDeltaX, timestamp), { a0 } = this.calculateAcceleration(isVertical ? velocitiesY : velocitiesX, v0, timestamp);
|
|
4727
4766
|
this._isMoving = false;
|
|
4728
4767
|
this.grabbing.set(false);
|
|
4729
4768
|
if (!this.snapIfNecessary(v0, false) && this.scrollBehavior() !== BEHAVIOR_INSTANT) {
|
|
@@ -4773,7 +4812,10 @@ class NgScrollView extends BaseScrollView {
|
|
|
4773
4812
|
$content.pipe(takeUntilDestroyed(this._destroyRef), switchMap$1(content => {
|
|
4774
4813
|
return fromEvent(content, TOUCH_START, { passive: false }).pipe(takeUntilDestroyed(this._destroyRef), filter$1(() => this._interactive), switchMap$1(e => {
|
|
4775
4814
|
touchCanceled = false;
|
|
4815
|
+
this._overscrollStartIteration = 0;
|
|
4816
|
+
this._overscrollApplied = false;
|
|
4776
4817
|
this._scrollDirection.clear();
|
|
4818
|
+
this._scrollDirectionValueX = this._scrollDirectionValueY = 0;
|
|
4777
4819
|
this.cancelOverscroll();
|
|
4778
4820
|
this.onDragStart();
|
|
4779
4821
|
this.stopScrolling(true);
|
|
@@ -4785,23 +4827,34 @@ class NgScrollView extends BaseScrollView {
|
|
|
4785
4827
|
const inversion = this._inversion, isVertical = this.isVertical();
|
|
4786
4828
|
this._isMoving = true;
|
|
4787
4829
|
this.grabbing.set(true);
|
|
4788
|
-
this.
|
|
4789
|
-
|
|
4830
|
+
this._startPositionX = this.x;
|
|
4831
|
+
this._startPositionY = this.y;
|
|
4832
|
+
let prevClientPositionX = (e.touches[e.touches.length - 1].clientX) * (this._horizontalAxisInvertion() ? -1 : 1), prevClientPositionY = e.touches[e.touches.length - 1].clientY, startClientPosX = prevClientPositionX, startClientPosY = prevClientPositionY, offsetsX = new Array(), offsetsY = new Array(), velocitiesX = new Array(), velocitiesY = new Array(), startTime = Date.now();
|
|
4790
4833
|
return fromEvent(window, TOUCH_MOVE, { passive: false }).pipe(takeUntilDestroyed(this._destroyRef), takeUntil$1($touchCanceler), tap(e => {
|
|
4791
4834
|
this.checkOverscroll(e);
|
|
4792
4835
|
}), switchMap$1(e => {
|
|
4793
|
-
const { position, currentPos, endTime, scrollDelta } = this.calculatePosition(
|
|
4794
|
-
|
|
4836
|
+
const { position: positionX, currentPos: currentPosX, endTime, scrollDelta: scrollDeltaX } = this.calculatePosition(false, true, this._horizontalAxisInvertion(), e, inversion, startClientPosX, startTime, prevClientPositionX, offsetsX, velocitiesX), { position: positionY, currentPos: currentPosY, scrollDelta: scrollDeltaY } = this.calculatePosition(true, true, false, e, inversion, startClientPosY, startTime, prevClientPositionY, offsetsY, velocitiesY), position = isVertical ? positionY : positionX;
|
|
4837
|
+
prevClientPositionX = currentPosX;
|
|
4838
|
+
prevClientPositionY = currentPosY;
|
|
4839
|
+
this._scrollDirectionValueX += Math.abs(scrollDeltaX);
|
|
4840
|
+
this._scrollDirectionValueY += Math.abs(scrollDeltaY);
|
|
4795
4841
|
this.move(isVertical, position, true, true, true);
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4842
|
+
if (this.isInfinity()) {
|
|
4843
|
+
const offset = Math.abs(position) - Math.abs(isVertical ? this._y : this._x), scrollSize = isVertical ? this.scrollHeight : this.scrollWidth, viewportSize = isVertical ? this.viewportBounds().height : this.viewportBounds().width;
|
|
4844
|
+
if (position >= (scrollSize - viewportSize * .5) || position <= 0) {
|
|
4845
|
+
if (isVertical) {
|
|
4846
|
+
startClientPosY -= offset;
|
|
4847
|
+
}
|
|
4848
|
+
else {
|
|
4849
|
+
startClientPosX -= offset;
|
|
4850
|
+
}
|
|
4851
|
+
}
|
|
4799
4852
|
}
|
|
4800
4853
|
startTime = endTime;
|
|
4801
4854
|
return race([fromEvent(window, TOUCH_END, { passive: false }), fromEvent(content, TOUCH_END, { passive: false })]).pipe(takeUntilDestroyed(this._destroyRef), takeUntil$1($touchCanceler), tap(e => {
|
|
4802
4855
|
touchCanceled = true;
|
|
4803
4856
|
this.cancelOverscroll();
|
|
4804
|
-
const endTime = Date.now(), timestamp = endTime - startTime, { v0 } = this.calculateVelocity(
|
|
4857
|
+
const endTime = Date.now(), timestamp = endTime - startTime, { v0 } = this.calculateVelocity(isVertical ? offsetsY : offsetsX, isVertical ? scrollDeltaY : scrollDeltaX, timestamp), { a0 } = this.calculateAcceleration(isVertical ? velocitiesY : velocitiesX, v0, timestamp);
|
|
4805
4858
|
this._isMoving = false;
|
|
4806
4859
|
this.grabbing.set(false);
|
|
4807
4860
|
if (!this.snapIfNecessary(v0, false) && this.scrollBehavior() !== BEHAVIOR_INSTANT) {
|
|
@@ -4883,8 +4936,11 @@ class NgScrollView extends BaseScrollView {
|
|
|
4883
4936
|
}
|
|
4884
4937
|
return false;
|
|
4885
4938
|
}
|
|
4886
|
-
calculatePosition(isVertical, e, inversion, startClientPos, startTime, prevClientPosition, offsets, velocities) {
|
|
4887
|
-
|
|
4939
|
+
calculatePosition(isVertical, enabled, axisInversion, e, inversion, startClientPos, startTime, prevClientPosition, offsets, velocities) {
|
|
4940
|
+
if (!enabled) {
|
|
4941
|
+
return { position: isVertical ? this._y : this._x, currentPos: null, endTime: Date.now(), scrollDelta: 0 };
|
|
4942
|
+
}
|
|
4943
|
+
const currentPos = (isVertical ? e.touches?.[e.touches?.length - 1]?.clientY || e.clientY : e.touches?.[e.touches?.length - 1]?.clientX || e.clientX) * (axisInversion ? -1 : 1), scrollSize = isVertical ? this.scrollHeight : this.scrollWidth, delta = (inversion ? -1 : 1) * (startClientPos - currentPos), dp = (isVertical ? this._startPositionY : this._startPositionX) + delta, position = this.isInfinity() ? dp : dp < 0 ? 0 : dp > scrollSize ? scrollSize : dp, endTime = Date.now(), timestamp = endTime - startTime, scrollDelta = (prevClientPosition === 0 || prevClientPosition === null) ? 0 : prevClientPosition - currentPos, { v0 } = this.calculateVelocity(offsets, scrollDelta, timestamp);
|
|
4888
4944
|
this.calculateAcceleration(velocities, v0, timestamp);
|
|
4889
4945
|
return { position, currentPos, endTime, scrollDelta };
|
|
4890
4946
|
}
|
|
@@ -4913,7 +4969,7 @@ class NgScrollView extends BaseScrollView {
|
|
|
4913
4969
|
}
|
|
4914
4970
|
}
|
|
4915
4971
|
}
|
|
4916
|
-
checkOverscroll(e) {
|
|
4972
|
+
checkOverscroll(e, wheel = false) {
|
|
4917
4973
|
if (!this._overscrollEnabled || !this.overscrollEnabled()) {
|
|
4918
4974
|
if (e.cancelable) {
|
|
4919
4975
|
e.stopImmediatePropagation();
|
|
@@ -4923,14 +4979,35 @@ class NgScrollView extends BaseScrollView {
|
|
|
4923
4979
|
}
|
|
4924
4980
|
if (this._overscrollEnabled) {
|
|
4925
4981
|
if (this.isVertical()) {
|
|
4926
|
-
|
|
4982
|
+
if (this._overscrollStartIteration < OVERSCROLL_START_ITERATION) {
|
|
4983
|
+
this._overscrollStartIteration++;
|
|
4984
|
+
this.checkOverscrollByAxis(e, this._y, this.scrollHeight);
|
|
4985
|
+
}
|
|
4986
|
+
else {
|
|
4987
|
+
if (wheel || this._overscrollApplied || this._scrollDirectionValueY > this._scrollDirectionValueX) {
|
|
4988
|
+
this._overscrollApplied = true;
|
|
4989
|
+
this.checkOverscrollByAxis(e, this._y, this.scrollHeight);
|
|
4990
|
+
}
|
|
4991
|
+
}
|
|
4927
4992
|
}
|
|
4928
4993
|
else {
|
|
4929
|
-
|
|
4994
|
+
if (this._overscrollStartIteration < OVERSCROLL_START_ITERATION) {
|
|
4995
|
+
this._overscrollStartIteration++;
|
|
4996
|
+
this.checkOverscrollByAxis(e, this._x, this.scrollWidth);
|
|
4997
|
+
}
|
|
4998
|
+
else {
|
|
4999
|
+
if (wheel || this._overscrollApplied || this._scrollDirectionValueX > this._scrollDirectionValueY) {
|
|
5000
|
+
this._overscrollApplied = true;
|
|
5001
|
+
this.checkOverscrollByAxis(e, this._x, this.scrollWidth);
|
|
5002
|
+
}
|
|
5003
|
+
}
|
|
4930
5004
|
}
|
|
4931
5005
|
}
|
|
4932
5006
|
}
|
|
4933
5007
|
calculateVelocity(offsets, delta, timestamp, indexOffset = 10) {
|
|
5008
|
+
if (offsets.length > MAX_VELOCITIES_LENGTH) {
|
|
5009
|
+
offsets.shift();
|
|
5010
|
+
}
|
|
4934
5011
|
offsets.push([delta, timestamp < ANIMATOR_MIN_TIMESTAMP ? ANIMATOR_MIN_TIMESTAMP : timestamp]);
|
|
4935
5012
|
const len = offsets.length, startIndex = len > indexOffset ? len - indexOffset : 0, lastVSign = calculateDirection(offsets), speedScale = this.scrollingSettings()?.speedScale ?? SPEED_SCALE;
|
|
4936
5013
|
let vSum = 0;
|
|
@@ -4946,7 +5023,10 @@ class NgScrollView extends BaseScrollView {
|
|
|
4946
5023
|
return { v0 };
|
|
4947
5024
|
}
|
|
4948
5025
|
calculateAcceleration(velocities, delta, timestamp, indexOffset = 10) {
|
|
4949
|
-
velocities.
|
|
5026
|
+
if (velocities.length > MAX_VELOCITIES_LENGTH) {
|
|
5027
|
+
velocities.shift();
|
|
5028
|
+
}
|
|
5029
|
+
velocities.push([Math.abs(delta) < MIN_DELTA ? 0 : delta, timestamp < ANIMATOR_MIN_TIMESTAMP ? ANIMATOR_MIN_TIMESTAMP : timestamp]);
|
|
4950
5030
|
const len = velocities.length, startIndex = len > indexOffset ? len - indexOffset : 0;
|
|
4951
5031
|
let aSum = 0, prevV0, iteration = 0, lastVSign = calculateDirection(velocities);
|
|
4952
5032
|
const mass = this.scrollingSettings()?.mass ?? MASS;
|
|
@@ -4964,7 +5044,7 @@ class NgScrollView extends BaseScrollView {
|
|
|
4964
5044
|
iteration++;
|
|
4965
5045
|
}
|
|
4966
5046
|
const a0 = aSum * (this.scrollingSettings()?.frictionalForce ?? FRICTION_FORCE);
|
|
4967
|
-
return { a0 };
|
|
5047
|
+
return { a0: Math.abs(a0) < MIN_ACCELERATION ? 0 : a0 };
|
|
4968
5048
|
}
|
|
4969
5049
|
stopScrolling(force = false) {
|
|
4970
5050
|
if (this._isAlignmentAnimation && !force) {
|
|
@@ -5673,6 +5753,13 @@ class NgScrollerComponent extends NgScrollView {
|
|
|
5673
5753
|
super();
|
|
5674
5754
|
this._filterId = `${this._service.id}-${MOTION_BLUR}`;
|
|
5675
5755
|
this._filter = `url(#${this._filterId})`;
|
|
5756
|
+
this.$resizeViewport.pipe(takeUntilDestroyed(), debounceTime(0), tap(() => {
|
|
5757
|
+
this.snapIfNeed();
|
|
5758
|
+
}), switchMap$1(() => {
|
|
5759
|
+
return this.$scroll.pipe(takeUntilDestroyed(this._destroyRef), take(1), tap(() => {
|
|
5760
|
+
this.snapIfNeed();
|
|
5761
|
+
}));
|
|
5762
|
+
})).subscribe();
|
|
5676
5763
|
const $filter = toObservable(this.filter), $motionBlur = toObservable(this.motionBlur), $maxMotionBlur = toObservable(this.maxMotionBlur), $motionBlurEnabled = toObservable(this.motionBlurEnabled), $isVertical = toObservable(this.isVertical);
|
|
5677
5764
|
const $scrollbarScroll = this.$scrollbarScroll;
|
|
5678
5765
|
$scrollbarScroll.pipe(takeUntilDestroyed(), debounceTime(50), tap(() => {
|
|
@@ -7731,7 +7818,7 @@ class NgVirtualListComponent {
|
|
|
7731
7818
|
this._trackBox.preventScrollSnapping(true);
|
|
7732
7819
|
const params = {
|
|
7733
7820
|
[this._isVertical ? TOP_PROP_NAME : LEFT_PROP_NAME]: pos, behavior, snap: false, normalize: true,
|
|
7734
|
-
fireUpdate:
|
|
7821
|
+
fireUpdate: true, blending: false, userAction: false,
|
|
7735
7822
|
duration: this.snapToItem() ? Math.max(this.animationParams().scrollToItem, this.animationParams().navigateToItem) : this.animationParams().navigateToItem,
|
|
7736
7823
|
};
|
|
7737
7824
|
scroller.scrollTo(params);
|