ng-virtual-list 19.9.2 → 19.9.4

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.
@@ -3230,7 +3230,6 @@ class NgScrollerComponent {
3230
3230
  this.updateScrollBar();
3231
3231
  }
3232
3232
  get y() { return this._y; }
3233
- _currentAnimation;
3234
3233
  _totalSize = 0;
3235
3234
  set totalSize(v) {
3236
3235
  this._totalSize = v;
@@ -3285,6 +3284,8 @@ class NgScrollerComponent {
3285
3284
  }
3286
3285
  };
3287
3286
  _updateScrollBarId;
3287
+ _animationId = -1;
3288
+ _animationId1 = -1;
3288
3289
  constructor() {
3289
3290
  this._service.$langTextDir.pipe(tap(v => {
3290
3291
  this.langTextDir.set(v);
@@ -3484,10 +3485,7 @@ class NgScrollerComponent {
3484
3485
  return { a0 };
3485
3486
  }
3486
3487
  stopScrolling() {
3487
- if (this._currentAnimation !== undefined) {
3488
- this._currentAnimation.cancel();
3489
- this._currentAnimation = undefined;
3490
- }
3488
+ cancelAnimationFrame(this._animationId);
3491
3489
  }
3492
3490
  move(isVertical, position, blending = false, userAction = false) {
3493
3491
  this.scrollTo({ [isVertical ? TOP : LEFT]: position, behavior: INSTANT, blending, userAction });
@@ -3518,7 +3516,7 @@ class NgScrollerComponent {
3518
3516
  this.x = start;
3519
3517
  }
3520
3518
  }
3521
- let finishedValue = endValue, isFinished = false, animationId;
3519
+ let finishedValue = endValue, isFinished = false;
3522
3520
  const step = (currentTime) => {
3523
3521
  if (!!isCanceled) {
3524
3522
  return;
@@ -3561,26 +3559,16 @@ class NgScrollerComponent {
3561
3559
  this._$scrollEnd.next(userAction);
3562
3560
  }
3563
3561
  else {
3564
- animationId = requestAnimationFrame(step);
3565
- }
3566
- }, cancel = () => {
3567
- cancelAnimationFrame(animationId);
3568
- isCanceled = true;
3569
- }, to = (value) => {
3570
- finishedValue = value;
3571
- }, finished = () => { return isFinished; };
3572
- animationId = requestAnimationFrame(step);
3573
- this._currentAnimation = {
3574
- cancel,
3575
- to,
3576
- finished,
3562
+ this._animationId = requestAnimationFrame(step);
3563
+ }
3577
3564
  };
3565
+ this._animationId = requestAnimationFrame(step);
3578
3566
  }
3579
3567
  updateScrollBar() {
3580
3568
  this._$updateScrollBar.next();
3581
3569
  }
3582
3570
  scrollTo(params) {
3583
- const posX = params.x || params.left || 0, posY = params.y || params.top || 0, userAction = params.userAction ?? false, x = posX, y = posY, behavior = params.behavior ?? INSTANT, blending = params.blending ?? true, scrollContent = this.scrollContent()?.nativeElement, isVertical = this.direction() === ScrollerDirection.VERTICAL;
3571
+ const posX = params.x || params.left || 0, posY = params.y || params.top || 0, userAction = params.userAction ?? false, x = posX, y = posY, fireUpdate = params.fireUpdate ?? true, behavior = params.behavior ?? INSTANT, blending = params.blending ?? true, scrollContent = this.scrollContent()?.nativeElement, isVertical = this.direction() === ScrollerDirection.VERTICAL;
3584
3572
  if (this._isMoving) {
3585
3573
  if (isVertical) {
3586
3574
  if (y < 0 || y > this.scrollHeight) {
@@ -3618,7 +3606,9 @@ class NgScrollerComponent {
3618
3606
  if (this.cdkScrollable) {
3619
3607
  this.cdkScrollable.getElementRef().nativeElement.dispatchEvent(SCROLL_EVENT);
3620
3608
  }
3621
- this._$scroll.next(userAction);
3609
+ if (fireUpdate) {
3610
+ this.fireScrollEvent(userAction);
3611
+ }
3622
3612
  }
3623
3613
  }
3624
3614
  else {
@@ -3630,11 +3620,16 @@ class NgScrollerComponent {
3630
3620
  if (this.cdkScrollable) {
3631
3621
  this.cdkScrollable.getElementRef().nativeElement.dispatchEvent(SCROLL_EVENT);
3632
3622
  }
3633
- this._$scroll.next(userAction);
3623
+ if (fireUpdate) {
3624
+ this.fireScrollEvent(userAction);
3625
+ }
3634
3626
  }
3635
3627
  }
3636
3628
  }
3637
3629
  }
3630
+ fireScrollEvent(userAction) {
3631
+ this._$scroll.next(userAction);
3632
+ }
3638
3633
  reset() {
3639
3634
  if (this.scrollBar) {
3640
3635
  this.scrollBar.stopScrolling();
@@ -4754,17 +4749,18 @@ class NgVirtualListComponent {
4754
4749
  if (roundedMaxPositionAfterUpdate > 0) {
4755
4750
  const diff = roundedMaxPositionAfterUpdate - roundedScrollPositionAfterUpdate, snapToEndTransitionInstantOffset = this.snapToEndTransitionInstantOffset() || viewportSize, animated = prepared && readyToStart && diff >= 0 && diff <= snapToEndTransitionInstantOffset, params = {
4756
4751
  [isVertical ? TOP_PROP_NAME : LEFT_PROP_NAME]: roundedMaxPositionAfterUpdate,
4752
+ fireUpdate: false,
4757
4753
  behavior: (animated ?
4758
4754
  BEHAVIOR_SMOOTH : BEHAVIOR_INSTANT),
4759
- blending: false,
4755
+ blending: true,
4760
4756
  };
4761
4757
  scroller?.scrollTo?.(params);
4762
4758
  }
4763
4759
  }
4764
4760
  else if (roundedActualScrollSize !== roundedScrollPositionAfterUpdate && scrollPositionAfterUpdate > 0) {
4765
4761
  const params = {
4766
- [isVertical ? TOP_PROP_NAME : LEFT_PROP_NAME]: scrollPositionAfterUpdate,
4767
- behavior: BEHAVIOR_INSTANT,
4762
+ [isVertical ? TOP_PROP_NAME : LEFT_PROP_NAME]: scrollPositionAfterUpdate, blending: true,
4763
+ fireUpdate: false, behavior: BEHAVIOR_INSTANT,
4768
4764
  };
4769
4765
  scroller.scrollTo(params);
4770
4766
  }
@@ -4773,25 +4769,10 @@ class NgVirtualListComponent {
4773
4769
  combineLatest([$snapScrollToBottom, $bounds, $listBounds, $scrollEndOffset, $actualItems, $itemConfigMap, $scrollSize, $itemSize,
4774
4770
  $bufferSize, $maxBufferSize, $snap, $isVertical, $dynamicSize, $enabledBufferOptimization, $cacheVersion, this.$userScroll,
4775
4771
  ]).pipe(takeUntilDestroyed(), distinctUntilChanged(), tap(([snapScrollToBottom, bounds, listBounds, scrollEndOffset, items, itemConfigMap, scrollSize, itemSize, bufferSize, maxBufferSize, snap, isVertical, dynamicSize, enabledBufferOptimization, cacheVersion,]) => {
4776
- const updateId = this._updateId;
4777
- if (updateId !== undefined) {
4778
- cancelAnimationFrame(updateId);
4779
- this._updateId = undefined;
4780
- }
4781
- if (!prepared || !isResetedReachStart) {
4782
- update({
4783
- snapScrollToBottom, bounds, listBounds, scrollEndOffset, items, itemConfigMap, scrollSize, itemSize,
4784
- bufferSize, maxBufferSize, snap, isVertical, dynamicSize, enabledBufferOptimization, cacheVersion,
4785
- });
4786
- }
4787
- else {
4788
- this._updateId = requestAnimationFrame((time) => {
4789
- update({
4790
- snapScrollToBottom, bounds, listBounds, scrollEndOffset, items, itemConfigMap, scrollSize, itemSize,
4791
- bufferSize, maxBufferSize, snap, isVertical, dynamicSize, enabledBufferOptimization, cacheVersion,
4792
- });
4793
- });
4794
- }
4772
+ update({
4773
+ snapScrollToBottom, bounds, listBounds, scrollEndOffset, items, itemConfigMap, scrollSize, itemSize,
4774
+ bufferSize, maxBufferSize, snap, isVertical, dynamicSize, enabledBufferOptimization, cacheVersion,
4775
+ });
4795
4776
  })).subscribe();
4796
4777
  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));
4797
4778
  $scroller.pipe(takeUntilDestroyed(), distinctUntilChanged(), switchMap$1(scroller => {
@@ -4918,7 +4899,7 @@ class NgVirtualListComponent {
4918
4899
  })).subscribe();
4919
4900
  const $scrollTo = this.$scrollTo;
4920
4901
  combineLatest([$scroller, $trackBy, $scrollTo]).pipe(takeUntilDestroyed(), filter$1(([scroller]) => scroller !== undefined), map(([scroller, trackBy, event]) => ({ scroller: scroller, trackBy, event })), switchMap$1(({ scroller, trackBy, event }) => {
4921
- const scrollerComponent = this._scrollerComponent(), { id, behavior = BEHAVIOR_INSTANT, iteration = 0, isLastIteration = false, scrollCalled = false, cb, } = event;
4902
+ const scrollerComponent = this._scrollerComponent(), { id, iteration = 0, isLastIteration = false, scrollCalled = false, cb, } = event;
4922
4903
  if (scrollerComponent) {
4923
4904
  const items = this._actualItems();
4924
4905
  if (items && items.length) {
@@ -4931,6 +4912,7 @@ class NgVirtualListComponent {
4931
4912
  snap: this.snap(), fromItemId: id, enabledBufferOptimization: this.enabledBufferOptimization(),
4932
4913
  }, scrollSize = this._trackBox.getItemPosition(id, itemConfigMap, opts), params = {
4933
4914
  [isVertical ? TOP_PROP_NAME : LEFT_PROP_NAME]: scrollSize, behavior: BEHAVIOR_INSTANT,
4915
+ fireUpdate: false,
4934
4916
  blending: true,
4935
4917
  };
4936
4918
  if (scrollSize === -1) {
@@ -4957,7 +4939,7 @@ class NgVirtualListComponent {
4957
4939
  if ((!notChanged && iteration < MAX_SCROLL_TO_ITERATIONS) || iteration < MAX_SCROLL_TO_ITERATIONS) {
4958
4940
  this._$scrollTo.next(params);
4959
4941
  return of([false, {
4960
- id, behavior: BEHAVIOR_INSTANT, scroller: scrollerComponent, iteration: iteration + 1, blending: true,
4942
+ id, scroller: scrollerComponent, iteration: iteration + 1,
4961
4943
  isLastIteration: notChanged, scrollCalled: true, cb
4962
4944
  }]).pipe(delay(1));
4963
4945
  }