ng-virtual-list 16.9.0 → 16.9.2

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.
@@ -3540,7 +3540,6 @@ class NgScrollerComponent {
3540
3540
  this.updateScrollBar();
3541
3541
  }
3542
3542
  get y() { return this._y; }
3543
- _currentAnimation;
3544
3543
  _totalSize = 0;
3545
3544
  set totalSize(v) {
3546
3545
  this._totalSize = v;
@@ -3598,6 +3597,8 @@ class NgScrollerComponent {
3598
3597
  };
3599
3598
  _updateScrollBarId;
3600
3599
  _destroyRef = inject(DestroyRef);
3600
+ _animationId = -1;
3601
+ _animationId1 = -1;
3601
3602
  constructor(_service) {
3602
3603
  this._service = _service;
3603
3604
  this._service.$langTextDir.pipe(tap(v => {
@@ -3801,10 +3802,7 @@ class NgScrollerComponent {
3801
3802
  return { a0 };
3802
3803
  }
3803
3804
  stopScrolling() {
3804
- if (this._currentAnimation !== undefined) {
3805
- this._currentAnimation.cancel();
3806
- this._currentAnimation = undefined;
3807
- }
3805
+ cancelAnimationFrame(this._animationId);
3808
3806
  }
3809
3807
  move(isVertical, position, blending = false, userAction = false) {
3810
3808
  this.scrollTo({ [isVertical ? TOP : LEFT]: position, behavior: INSTANT, blending, userAction });
@@ -3835,7 +3833,7 @@ class NgScrollerComponent {
3835
3833
  this.x = start;
3836
3834
  }
3837
3835
  }
3838
- let finishedValue = endValue, isFinished = false, animationId;
3836
+ let finishedValue = endValue, isFinished = false;
3839
3837
  const step = (currentTime) => {
3840
3838
  if (!!isCanceled) {
3841
3839
  return;
@@ -3878,26 +3876,16 @@ class NgScrollerComponent {
3878
3876
  this._$scrollEnd.next(userAction);
3879
3877
  }
3880
3878
  else {
3881
- animationId = requestAnimationFrame(step);
3882
- }
3883
- }, cancel = () => {
3884
- cancelAnimationFrame(animationId);
3885
- isCanceled = true;
3886
- }, to = (value) => {
3887
- finishedValue = value;
3888
- }, finished = () => { return isFinished; };
3889
- animationId = requestAnimationFrame(step);
3890
- this._currentAnimation = {
3891
- cancel,
3892
- to,
3893
- finished,
3879
+ this._animationId = requestAnimationFrame(step);
3880
+ }
3894
3881
  };
3882
+ this._animationId = requestAnimationFrame(step);
3895
3883
  }
3896
3884
  updateScrollBar() {
3897
3885
  this._$updateScrollBar.next();
3898
3886
  }
3899
3887
  scrollTo(params) {
3900
- 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.getValue() === ScrollerDirection.VERTICAL;
3888
+ 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, fireUpdate = params.fireUpdate ?? true, scrollContent = this.scrollContent?.nativeElement, isVertical = this._$direction.getValue() === ScrollerDirection.VERTICAL;
3901
3889
  if (this._isMoving) {
3902
3890
  if (isVertical) {
3903
3891
  if (y < 0 || y > this.scrollHeight) {
@@ -3935,7 +3923,9 @@ class NgScrollerComponent {
3935
3923
  if (this.cdkScrollable) {
3936
3924
  this.cdkScrollable.getElementRef().nativeElement.dispatchEvent(SCROLL_EVENT);
3937
3925
  }
3938
- this._$scroll.next(userAction);
3926
+ if (fireUpdate) {
3927
+ this.fireScrollEvent(userAction);
3928
+ }
3939
3929
  }
3940
3930
  }
3941
3931
  else {
@@ -3947,11 +3937,16 @@ class NgScrollerComponent {
3947
3937
  if (this.cdkScrollable) {
3948
3938
  this.cdkScrollable.getElementRef().nativeElement.dispatchEvent(SCROLL_EVENT);
3949
3939
  }
3950
- this._$scroll.next(userAction);
3940
+ if (fireUpdate) {
3941
+ this.fireScrollEvent(userAction);
3942
+ }
3951
3943
  }
3952
3944
  }
3953
3945
  }
3954
3946
  }
3947
+ fireScrollEvent(userAction) {
3948
+ this._$scroll.next(userAction);
3949
+ }
3955
3950
  reset() {
3956
3951
  if (this.scrollBar) {
3957
3952
  this.scrollBar.stopScrolling();
@@ -5363,7 +5358,8 @@ class NgVirtualListComponent {
5363
5358
  [isVertical ? TOP_PROP_NAME : LEFT_PROP_NAME]: roundedMaxPositionAfterUpdate,
5364
5359
  behavior: (animated ?
5365
5360
  BEHAVIOR_SMOOTH : BEHAVIOR_INSTANT),
5366
- blending: false,
5361
+ blending: true,
5362
+ fireUpdate: false,
5367
5363
  };
5368
5364
  scroller?.scrollTo?.(params);
5369
5365
  }
@@ -5371,7 +5367,8 @@ class NgVirtualListComponent {
5371
5367
  else if (roundedActualScrollSize !== roundedScrollPositionAfterUpdate && scrollPositionAfterUpdate > 0) {
5372
5368
  const params = {
5373
5369
  [isVertical ? TOP_PROP_NAME : LEFT_PROP_NAME]: scrollPositionAfterUpdate,
5374
- behavior: BEHAVIOR_INSTANT,
5370
+ behavior: BEHAVIOR_INSTANT, blending: true,
5371
+ fireUpdate: false,
5375
5372
  };
5376
5373
  scroller.scrollTo(params);
5377
5374
  }
@@ -5380,25 +5377,10 @@ class NgVirtualListComponent {
5380
5377
  combineLatest([$snapScrollToBottom, $bounds, $listBounds, $scrollEndOffset, $actualItems, $itemConfigMap, $scrollSize, $itemSize,
5381
5378
  $bufferSize, $maxBufferSize, $snap, $isVertical, $dynamicSize, $enabledBufferOptimization, $cacheVersion, this.$userScroll,
5382
5379
  ]).pipe(takeUntilDestroyed(), distinctUntilChanged(), tap(([snapScrollToBottom, bounds, listBounds, scrollEndOffset, items, itemConfigMap, scrollSize, itemSize, bufferSize, maxBufferSize, snap, isVertical, dynamicSize, enabledBufferOptimization, cacheVersion,]) => {
5383
- const updateId = this._updateId;
5384
- if (updateId !== undefined) {
5385
- cancelAnimationFrame(updateId);
5386
- this._updateId = undefined;
5387
- }
5388
- if (!prepared || !isResetedReachStart) {
5389
- update({
5390
- snapScrollToBottom, bounds: bounds, listBounds: listBounds, scrollEndOffset, items, itemConfigMap, scrollSize, itemSize,
5391
- bufferSize, maxBufferSize, snap, isVertical, dynamicSize, enabledBufferOptimization, cacheVersion,
5392
- });
5393
- }
5394
- else {
5395
- this._updateId = requestAnimationFrame((time) => {
5396
- update({
5397
- snapScrollToBottom, bounds: bounds, listBounds: listBounds, scrollEndOffset, items, itemConfigMap, scrollSize, itemSize,
5398
- bufferSize, maxBufferSize, snap, isVertical, dynamicSize, enabledBufferOptimization, cacheVersion,
5399
- });
5400
- });
5401
- }
5380
+ update({
5381
+ snapScrollToBottom, bounds: bounds, listBounds: listBounds, scrollEndOffset, items, itemConfigMap, scrollSize, itemSize,
5382
+ bufferSize, maxBufferSize, snap, isVertical, dynamicSize, enabledBufferOptimization, cacheVersion,
5383
+ });
5402
5384
  })).subscribe();
5403
5385
  const $scroller = this.$scroller.pipe(takeUntilDestroyed(), filter$1(v => !!v), map(v => v.nativeElement), take(1)), $list = this.$list.pipe(takeUntilDestroyed(), filter$1(v => !!v), map(v => v.nativeElement), take(1)), $scrollerScroll = this.$viewInitialized.pipe(takeUntilDestroyed(), filter$1(v => !!v), switchMap$1(() => of(this._scrollerComponent).pipe(filter$1(v => !!v), switchMap$1(scroller => scroller.$scroll)))), $scrollerScrollEnd = this.$viewInitialized.pipe(takeUntilDestroyed(), filter$1(v => !!v), switchMap$1(() => of(this._scrollerComponent).pipe(filter$1(v => !!v), switchMap$1(scroller => scroller.$scrollEnd))));
5404
5386
  $scroller.pipe(takeUntilDestroyed(), distinctUntilChanged(), switchMap$1(scroller => {
@@ -5525,7 +5507,7 @@ class NgVirtualListComponent {
5525
5507
  })).subscribe();
5526
5508
  const $scrollTo = this.$scrollTo;
5527
5509
  combineLatest([$scroller, $trackBy, $scrollTo]).pipe(takeUntilDestroyed(), filter$1(([scroller]) => scroller !== undefined), map(([scroller, trackBy, event]) => ({ scroller: scroller, trackBy, event })), switchMap$1(({ scroller, trackBy, event }) => {
5528
- const scrollerComponent = this._scrollerComponent, { id, behavior = BEHAVIOR_INSTANT, iteration = 0, isLastIteration = false, scrollCalled = false, cb, } = event;
5510
+ const scrollerComponent = this._scrollerComponent, { id, iteration = 0, isLastIteration = false, scrollCalled = false, cb, } = event;
5529
5511
  if (scrollerComponent) {
5530
5512
  const items = this._$actualItems.getValue();
5531
5513
  if (items && items.length) {
@@ -5538,7 +5520,7 @@ class NgVirtualListComponent {
5538
5520
  snap: this._$snap.getValue(), fromItemId: id, enabledBufferOptimization: this._$enabledBufferOptimization.getValue(),
5539
5521
  }, scrollSize = this._trackBox.getItemPosition(id, itemConfigMap, opts), params = {
5540
5522
  [isVertical ? TOP_PROP_NAME : LEFT_PROP_NAME]: scrollSize, behavior: BEHAVIOR_INSTANT,
5541
- blending: true,
5523
+ blending: true, fireUpdate: false,
5542
5524
  };
5543
5525
  if (scrollSize === -1) {
5544
5526
  return of([true, { id, scroller: scrollerComponent, scrollCalled, cb }]);
@@ -5564,7 +5546,7 @@ class NgVirtualListComponent {
5564
5546
  if ((!notChanged && iteration < MAX_SCROLL_TO_ITERATIONS) || iteration < MAX_SCROLL_TO_ITERATIONS) {
5565
5547
  this._$scrollTo.next(params);
5566
5548
  return of([false, {
5567
- id, behavior: BEHAVIOR_INSTANT, scroller: scrollerComponent, iteration: iteration + 1, blending: true,
5549
+ id, scroller: scrollerComponent, iteration: iteration + 1,
5568
5550
  isLastIteration: notChanged, scrollCalled: true, cb
5569
5551
  }]).pipe(delay(1));
5570
5552
  }