ng-virtual-list 19.1.28 → 19.1.30

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.
@@ -28,7 +28,6 @@ const DEFAULT_ITEMS_OFFSET = 2;
28
28
  const DEFAULT_LIST_SIZE = 400;
29
29
  const DEFAULT_SNAP = false;
30
30
  const DEFAULT_ENABLED_BUFFER_OPTIMIZATION = false;
31
- const DEFAULT_SNAP_TO_ITEM = false;
32
31
  const DEFAULT_DYNAMIC_SIZE = false;
33
32
  const TRACK_BY_PROPERTY_NAME = 'id';
34
33
  const DEFAULT_DIRECTION = Directions.VERTICAL;
@@ -112,8 +111,8 @@ class NgVirtualListItemComponent {
112
111
  ? 0 : NgVirtualListItemComponent.__nextId + 1;
113
112
  }
114
113
  getBounds() {
115
- const el = this._elementRef.nativeElement, { width, height, left, top } = el.getBoundingClientRect();
116
- return { width, height, x: left, y: top };
114
+ const el = this._elementRef.nativeElement, { width, height } = el.getBoundingClientRect();
115
+ return { width, height };
117
116
  }
118
117
  show() {
119
118
  const styles = this._elementRef.nativeElement.style;
@@ -397,6 +396,33 @@ class EventEmitter {
397
396
  }
398
397
  }
399
398
 
399
+ class CMap {
400
+ _dict = {};
401
+ constructor(dict) {
402
+ if (dict) {
403
+ this._dict = { ...dict._dict };
404
+ }
405
+ }
406
+ get(key) {
407
+ const k = String(key);
408
+ return this._dict[k];
409
+ }
410
+ set(key, value) {
411
+ const k = String(key);
412
+ this._dict[k] = value;
413
+ return this;
414
+ }
415
+ has(key) {
416
+ return this._dict.hasOwnProperty(String(key));
417
+ }
418
+ delete(key) {
419
+ const k = String(key);
420
+ delete this._dict[k];
421
+ }
422
+ clear() {
423
+ this._dict = {};
424
+ }
425
+ }
400
426
  const MAX_SCROLL_DIRECTION_POOL = 50, CLEAR_SCROLL_DIRECTION_TO = 10;
401
427
  /**
402
428
  * Cache map.
@@ -406,8 +432,8 @@ const MAX_SCROLL_DIRECTION_POOL = 50, CLEAR_SCROLL_DIRECTION_TO = 10;
406
432
  * @email djonnyx@gmail.com
407
433
  */
408
434
  class CacheMap extends EventEmitter {
409
- _map = new Map();
410
- _snapshot = new Map();
435
+ _map = new CMap();
436
+ _snapshot = new CMap();
411
437
  _version = 0;
412
438
  _delta = 0;
413
439
  get delta() {
@@ -491,11 +517,8 @@ class CacheMap extends EventEmitter {
491
517
  get(id) {
492
518
  return this._map.get(id);
493
519
  }
494
- forEach(callbackfn, thisArg) {
495
- return this._map.forEach(callbackfn, thisArg);
496
- }
497
520
  snapshot() {
498
- this._snapshot = new Map(this._map);
521
+ this._snapshot = new CMap(this._map);
499
522
  }
500
523
  dispose() {
501
524
  super.dispose();
@@ -560,10 +583,16 @@ class TrackBox extends CacheMap {
560
583
  this.dispatch(TRACK_BOX_CHANGE_EVENT_NAME, version);
561
584
  };
562
585
  _previousCollection;
586
+ _deletedItemsMap = {};
587
+ _crudDetected = false;
588
+ get crudDetected() { return this._crudDetected; }
563
589
  _debounceChanges = debounce(this._fireChanges, 0);
564
590
  fireChange() {
565
591
  this._debounceChanges.execute(this._version);
566
592
  }
593
+ _previousTotalSize = 0;
594
+ _scrollDelta = 0;
595
+ get scrollDelta() { return this._scrollDelta; }
567
596
  /**
568
597
  * Scans the collection for deleted items and flushes the deleted item cache.
569
598
  */
@@ -579,11 +608,13 @@ class TrackBox extends CacheMap {
579
608
  * Update the cache of items from the list
580
609
  */
581
610
  updateCache(previousCollection, currentCollection, itemSize) {
611
+ let crudDetected = false;
582
612
  if (!currentCollection || currentCollection.length === 0) {
583
613
  if (previousCollection) {
584
614
  // deleted
585
615
  for (let i = 0, l = previousCollection.length; i < l; i++) {
586
616
  const item = previousCollection[i], id = item.id;
617
+ crudDetected = true;
587
618
  if (this._map.has(id)) {
588
619
  this._map.delete(id);
589
620
  }
@@ -595,8 +626,9 @@ class TrackBox extends CacheMap {
595
626
  if (currentCollection) {
596
627
  // added
597
628
  for (let i = 0, l = currentCollection.length; i < l; i++) {
629
+ crudDetected = true;
598
630
  const item = currentCollection[i], id = item.id;
599
- this._map.set(id, { x: 0, y: 0, width: itemSize, height: itemSize, method: ItemDisplayMethods.CREATE });
631
+ this._map.set(id, { width: itemSize, height: itemSize, method: ItemDisplayMethods.CREATE });
600
632
  }
601
633
  }
602
634
  return;
@@ -608,7 +640,7 @@ class TrackBox extends CacheMap {
608
640
  collectionDict[item.id] = item;
609
641
  }
610
642
  }
611
- const notChangedMap = {}, deletedMap = {}, updatedMap = {};
643
+ const notChangedMap = {}, deletedMap = {}, deletedItemsMap = {}, updatedMap = {};
612
644
  for (let i = 0, l = previousCollection.length; i < l; i++) {
613
645
  const item = previousCollection[i], id = item.id;
614
646
  if (item) {
@@ -616,18 +648,21 @@ class TrackBox extends CacheMap {
616
648
  if (item === collectionDict[id]) {
617
649
  // not changed
618
650
  notChangedMap[item.id] = item;
619
- this._map.set(id, { ...(this._map.get(id) || { x: 0, y: 0, width: itemSize, height: itemSize }), method: ItemDisplayMethods.NOT_CHANGED });
651
+ this._map.set(id, { ...(this._map.get(id) || { width: itemSize, height: itemSize }), method: ItemDisplayMethods.NOT_CHANGED });
620
652
  continue;
621
653
  }
622
654
  else {
623
655
  // updated
656
+ crudDetected = true;
624
657
  updatedMap[item.id] = item;
625
- this._map.set(id, { ...(this._map.get(id) || { x: 0, y: 0, width: itemSize, height: itemSize }), method: ItemDisplayMethods.UPDATE });
658
+ this._map.set(id, { ...(this._map.get(id) || { width: itemSize, height: itemSize }), method: ItemDisplayMethods.UPDATE });
626
659
  continue;
627
660
  }
628
661
  }
629
662
  // deleted
663
+ crudDetected = true;
630
664
  deletedMap[item.id] = item;
665
+ deletedItemsMap[i] = this._map.get(item.id);
631
666
  this._map.delete(id);
632
667
  }
633
668
  }
@@ -635,32 +670,51 @@ class TrackBox extends CacheMap {
635
670
  const item = currentCollection[i], id = item.id;
636
671
  if (item && !deletedMap.hasOwnProperty(id) && !updatedMap.hasOwnProperty(id) && !notChangedMap.hasOwnProperty(id)) {
637
672
  // added
638
- this._map.set(id, { x: 0, y: 0, width: itemSize, height: itemSize, method: ItemDisplayMethods.CREATE });
673
+ crudDetected = true;
674
+ this._map.set(id, { width: itemSize, height: itemSize, method: ItemDisplayMethods.CREATE });
639
675
  }
640
676
  }
677
+ this._crudDetected = crudDetected;
678
+ this._deletedItemsMap = deletedItemsMap;
641
679
  }
642
680
  /**
643
681
  * Finds the position of a collection element by the given Id
644
682
  */
645
683
  getItemPosition(id, stickyMap, options) {
646
684
  const opt = { fromItemId: id, stickyMap, ...options };
647
- const { scrollSize } = this.recalculateMetrics(opt);
685
+ const { scrollSize } = this.recalculateMetrics({
686
+ ...opt,
687
+ dynamicSize: this._crudDetected || opt.dynamicSize,
688
+ previousTotalSize: this._previousTotalSize,
689
+ crudDetected: this._crudDetected,
690
+ deletedItemsMap: this._deletedItemsMap,
691
+ });
648
692
  return scrollSize;
649
693
  }
650
694
  /**
651
695
  * Updates the collection of display objects
652
696
  */
653
697
  updateCollection(items, stickyMap, options) {
654
- const opt = { stickyMap, ...options };
655
- this.cacheElements();
698
+ const opt = { stickyMap, ...options }, crudDetected = this._crudDetected, deletedItemsMap = this._deletedItemsMap;
699
+ if (opt.dynamicSize) {
700
+ this.cacheElements();
701
+ }
656
702
  const metrics = this.recalculateMetrics({
657
703
  ...opt,
658
704
  collection: items,
705
+ previousTotalSize: this._previousTotalSize,
706
+ crudDetected: this._crudDetected,
707
+ deletedItemsMap,
659
708
  });
660
709
  this._delta += metrics.delta;
661
- this.snapshot();
662
- const displayItems = this.generateDisplayCollection(items, stickyMap, metrics);
663
- return { displayItems, totalSize: metrics.totalSize, delta: metrics.delta };
710
+ this._previousTotalSize = metrics.totalSize;
711
+ this._deletedItemsMap = {};
712
+ this._crudDetected = false;
713
+ if (opt.dynamicSize) {
714
+ this.snapshot();
715
+ }
716
+ const displayItems = this.generateDisplayCollection(items, stickyMap, { ...metrics, });
717
+ return { displayItems, totalSize: metrics.totalSize, delta: metrics.delta, crudDetected };
664
718
  }
665
719
  /**
666
720
  * Finds the closest element in the collection by scrollSize
@@ -719,7 +773,7 @@ class TrackBox extends CacheMap {
719
773
  * Calculates list metrics
720
774
  */
721
775
  recalculateMetrics(options) {
722
- const { fromItemId, bounds, collection, dynamicSize, isVertical, itemSize, itemsOffset, scrollSize, snap, stickyMap, enabledBufferOptimization } = options;
776
+ const { fromItemId, bounds, collection, dynamicSize, isVertical, itemSize, itemsOffset, scrollSize, snap, stickyMap, enabledBufferOptimization, previousTotalSize, crudDetected, deletedItemsMap } = options;
723
777
  const { width, height } = bounds, sizeProperty = isVertical ? HEIGHT_PROP_NAME : WIDTH_PROP_NAME, size = isVertical ? height : width, totalLength = collection.length, typicalItemSize = itemSize, w = isVertical ? width : typicalItemSize, h = isVertical ? typicalItemSize : height, map = this._map, snapshot = this._snapshot, checkOverscrollItemsLimit = Math.ceil(size / typicalItemSize), snippedPos = Math.floor(scrollSize), leftItemsWeights = [], isFromId = fromItemId !== undefined && (typeof fromItemId === 'number' && fromItemId > -1)
724
778
  || (typeof fromItemId === 'string' && fromItemId > '-1');
725
779
  let leftItemsOffset = 0, rightItemsOffset = 0;
@@ -744,32 +798,36 @@ class TrackBox extends CacheMap {
744
798
  else {
745
799
  leftItemsOffset = rightItemsOffset = itemsOffset;
746
800
  }
747
- let itemsFromStartToScrollEnd = -1, itemsFromDisplayEndToOffsetEnd = 0, itemsFromStartToDisplayEnd = -1, leftItemLength = 0, rightItemLength = 0, leftItemsWeight = 0, rightItemsWeight = 0, leftHiddenItemsWeight = 0, totalItemsToDisplayEndWeight = 0, rightSizeOfAddedItems = 0, leftSizeOfAddedItems = 0, rightSizeOfUpdatedItems = 0, leftSizeOfUpdatedItems = 0, itemById = undefined, itemByIdPos = 0, targetDisplayItemIndex = -1, isTargetInOverscroll = false, actualScrollSize = itemByIdPos, totalSize = 0, startIndex;
801
+ let itemsFromStartToScrollEnd = -1, itemsFromDisplayEndToOffsetEnd = 0, itemsFromStartToDisplayEnd = -1, leftItemLength = 0, rightItemLength = 0, leftItemsWeight = 0, rightItemsWeight = 0, leftHiddenItemsWeight = 0, totalItemsToDisplayEndWeight = 0, leftSizeOfAddedItems = 0, leftSizeOfUpdatedItems = 0, leftSizeOfDeletedItems = 0, itemById = undefined, itemByIdPos = 0, targetDisplayItemIndex = -1, isTargetInOverscroll = false, actualScrollSize = itemByIdPos, totalSize = 0, startIndex;
748
802
  // If the list is dynamic or there are new elements in the collection, then it switches to the long algorithm.
749
803
  if (dynamicSize) {
750
- let y = 0, stickyCollectionItem = undefined, stickyComponentSize = 0, stickyComponentIndex = -1;
804
+ let y = 0, stickyCollectionItem = undefined, stickyComponentSize = 0;
751
805
  for (let i = 0, l = collection.length; i < l; i++) {
752
806
  const ii = i + 1, collectionItem = collection[i], id = collectionItem.id;
753
807
  let componentSize = 0, componentSizeDelta = 0, itemDisplayMethod = ItemDisplayMethods.NOT_CHANGED;
754
808
  if (map.has(id)) {
755
- const bounds = map.get(id) || { x: 0, y: 0, width: typicalItemSize, height: typicalItemSize };
809
+ const bounds = map.get(id) || { width: typicalItemSize, height: typicalItemSize };
756
810
  componentSize = bounds[sizeProperty];
757
811
  itemDisplayMethod = bounds?.method ?? ItemDisplayMethods.UPDATE;
758
- if (itemDisplayMethod === ItemDisplayMethods.UPDATE) {
759
- const snapshotBounds = snapshot.get(id);
760
- const componentSnapshotSize = componentSize - (snapshotBounds ? snapshotBounds[sizeProperty] : typicalItemSize);
761
- componentSizeDelta = componentSnapshotSize;
762
- map.set(id, { ...bounds, method: ItemDisplayMethods.NOT_CHANGED });
763
- }
764
- if (itemDisplayMethod === ItemDisplayMethods.CREATE) {
765
- componentSizeDelta = typicalItemSize;
766
- map.set(id, { ...bounds, method: ItemDisplayMethods.NOT_CHANGED });
812
+ switch (itemDisplayMethod) {
813
+ case ItemDisplayMethods.UPDATE: {
814
+ const snapshotBounds = snapshot.get(id);
815
+ const componentSnapshotSize = componentSize - (snapshotBounds ? snapshotBounds[sizeProperty] : typicalItemSize);
816
+ componentSizeDelta = componentSnapshotSize;
817
+ map.set(id, { ...bounds, method: ItemDisplayMethods.NOT_CHANGED });
818
+ break;
819
+ }
820
+ case ItemDisplayMethods.CREATE: {
821
+ componentSizeDelta = typicalItemSize;
822
+ map.set(id, { ...bounds, method: ItemDisplayMethods.NOT_CHANGED });
823
+ break;
824
+ }
767
825
  }
768
826
  }
769
- else {
770
- componentSize = typicalItemSize;
771
- if (snapshot.has(id)) {
772
- itemDisplayMethod = ItemDisplayMethods.DELETE;
827
+ if (this._deletedItemsMap.hasOwnProperty(i)) {
828
+ const bounds = this._deletedItemsMap[i], size = bounds[sizeProperty] ?? typicalItemSize;
829
+ if (y < scrollSize - size) {
830
+ leftSizeOfDeletedItems += size;
773
831
  }
774
832
  }
775
833
  totalSize += componentSize;
@@ -778,7 +836,6 @@ class TrackBox extends CacheMap {
778
836
  if (id !== fromItemId && stickyMap && stickyMap[id] > 0) {
779
837
  stickyComponentSize = componentSize;
780
838
  stickyCollectionItem = collectionItem;
781
- stickyComponentIndex = i;
782
839
  }
783
840
  if (id === fromItemId) {
784
841
  targetDisplayItemIndex = i;
@@ -821,22 +878,25 @@ class TrackBox extends CacheMap {
821
878
  totalItemsToDisplayEndWeight += componentSize;
822
879
  itemsFromDisplayEndToOffsetEnd = itemsFromStartToDisplayEnd + rightItemsOffset;
823
880
  }
824
- if (y > itemByIdPos + size + componentSize) {
825
- if (itemDisplayMethod === ItemDisplayMethods.UPDATE) {
826
- rightSizeOfAddedItems += componentSizeDelta;
827
- }
828
- }
829
881
  }
830
882
  else if (y < scrollSize + size + componentSize) {
831
883
  itemsFromStartToDisplayEnd = ii;
832
884
  totalItemsToDisplayEndWeight += componentSize;
833
885
  itemsFromDisplayEndToOffsetEnd = itemsFromStartToDisplayEnd + rightItemsOffset;
834
886
  if (y < scrollSize - componentSize) {
835
- if (itemDisplayMethod === ItemDisplayMethods.UPDATE) {
836
- leftSizeOfUpdatedItems += componentSizeDelta;
837
- }
838
- if (itemDisplayMethod === ItemDisplayMethods.CREATE) {
839
- leftSizeOfAddedItems += componentSizeDelta;
887
+ switch (itemDisplayMethod) {
888
+ case ItemDisplayMethods.CREATE: {
889
+ leftSizeOfAddedItems += componentSizeDelta;
890
+ break;
891
+ }
892
+ case ItemDisplayMethods.UPDATE: {
893
+ leftSizeOfUpdatedItems += componentSizeDelta;
894
+ break;
895
+ }
896
+ case ItemDisplayMethods.DELETE: {
897
+ leftSizeOfDeletedItems += componentSizeDelta;
898
+ break;
899
+ }
840
900
  }
841
901
  }
842
902
  }
@@ -844,12 +904,6 @@ class TrackBox extends CacheMap {
844
904
  if (i < itemsFromDisplayEndToOffsetEnd) {
845
905
  rightItemsWeight += componentSize;
846
906
  }
847
- if (itemDisplayMethod === ItemDisplayMethods.UPDATE) {
848
- rightSizeOfUpdatedItems += componentSizeDelta;
849
- }
850
- if (itemDisplayMethod === ItemDisplayMethods.CREATE) {
851
- rightSizeOfAddedItems += componentSizeDelta;
852
- }
853
907
  }
854
908
  y += componentSize;
855
909
  }
@@ -877,6 +931,43 @@ class TrackBox extends CacheMap {
877
931
  else
878
932
  // Buffer optimization does not work on fast linear algorithm
879
933
  {
934
+ if (crudDetected) {
935
+ let y = 0;
936
+ for (let i = 0, l = collection.length; i < l; i++) {
937
+ const collectionItem = collection[i], id = collectionItem.id;
938
+ let componentSize = typicalItemSize, itemDisplayMethod = ItemDisplayMethods.NOT_CHANGED;
939
+ if (map.has(id)) {
940
+ const bounds = map.get(id);
941
+ itemDisplayMethod = bounds?.method ?? ItemDisplayMethods.UPDATE;
942
+ if (itemDisplayMethod === ItemDisplayMethods.CREATE) {
943
+ map.set(id, { ...bounds, method: ItemDisplayMethods.NOT_CHANGED });
944
+ }
945
+ }
946
+ if (this._deletedItemsMap.hasOwnProperty(i)) {
947
+ const bounds = this._deletedItemsMap[i], size = bounds[sizeProperty] ?? typicalItemSize;
948
+ if (y < scrollSize - size) {
949
+ leftSizeOfDeletedItems += size;
950
+ }
951
+ }
952
+ if (y < scrollSize - componentSize) {
953
+ switch (itemDisplayMethod) {
954
+ case ItemDisplayMethods.CREATE: {
955
+ leftSizeOfUpdatedItems += componentSize;
956
+ break;
957
+ }
958
+ case ItemDisplayMethods.UPDATE: {
959
+ leftSizeOfUpdatedItems += componentSize;
960
+ break;
961
+ }
962
+ case ItemDisplayMethods.DELETE: {
963
+ leftSizeOfDeletedItems += componentSize;
964
+ break;
965
+ }
966
+ }
967
+ }
968
+ y += componentSize;
969
+ }
970
+ }
880
971
  itemsFromStartToScrollEnd = Math.floor(scrollSize / typicalItemSize);
881
972
  itemsFromStartToDisplayEnd = Math.ceil((scrollSize + size) / typicalItemSize);
882
973
  leftItemLength = Math.min(itemsFromStartToScrollEnd, itemsOffset);
@@ -886,11 +977,12 @@ class TrackBox extends CacheMap {
886
977
  rightItemsWeight = rightItemLength * typicalItemSize,
887
978
  leftHiddenItemsWeight = itemsFromStartToScrollEnd * typicalItemSize,
888
979
  totalItemsToDisplayEndWeight = itemsFromStartToDisplayEnd * typicalItemSize;
889
- actualScrollSize = scrollSize;
890
980
  totalSize = totalLength * typicalItemSize;
981
+ const k = totalSize !== 0 ? previousTotalSize / totalSize : 0;
982
+ actualScrollSize = scrollSize * k;
891
983
  }
892
984
  startIndex = Math.min(itemsFromStartToScrollEnd - leftItemLength, totalLength > 0 ? totalLength - 1 : 0);
893
- const itemsOnDisplay = totalItemsToDisplayEndWeight - leftHiddenItemsWeight, itemsOnDisplayLength = itemsFromStartToDisplayEnd - itemsFromStartToScrollEnd, startPosition = leftHiddenItemsWeight - leftItemsWeight, renderItems = itemsOnDisplayLength + leftItemLength + rightItemLength, delta = leftSizeOfUpdatedItems + leftSizeOfAddedItems;
985
+ const itemsOnDisplay = totalItemsToDisplayEndWeight - leftHiddenItemsWeight, itemsOnDisplayLength = itemsFromStartToDisplayEnd - itemsFromStartToScrollEnd, startPosition = leftHiddenItemsWeight - leftItemsWeight, renderItems = itemsOnDisplayLength + leftItemLength + rightItemLength, delta = leftSizeOfUpdatedItems + leftSizeOfAddedItems - leftSizeOfDeletedItems;
894
986
  const metrics = {
895
987
  delta,
896
988
  normalizedItemWidth: w,
@@ -912,7 +1004,6 @@ class TrackBox extends CacheMap {
912
1004
  rightItemsWeight,
913
1005
  scrollSize: actualScrollSize,
914
1006
  leftSizeOfAddedItems,
915
- rightSizeOfAddedItems,
916
1007
  sizeProperty,
917
1008
  snap,
918
1009
  snippedPos,
@@ -925,8 +1016,6 @@ class TrackBox extends CacheMap {
925
1016
  };
926
1017
  return metrics;
927
1018
  }
928
- _scrollDelta = 0;
929
- get scrollDelta() { return this._scrollDelta; }
930
1019
  clearDeltaDirection() {
931
1020
  this.clearScrollDirectionCache();
932
1021
  }
@@ -1204,11 +1293,7 @@ class NgVirtualListComponent {
1204
1293
  this.clearScrollToRepeatExecutionTimeout();
1205
1294
  const container = this._container()?.nativeElement;
1206
1295
  if (container) {
1207
- const dynamicSize = this.dynamicSize(), delta = this._trackBox.delta, scrollSize = (this._isVertical ? container.scrollTop : container.scrollLeft);
1208
- let actualScrollSize = scrollSize, isScrollIUmmediate = false;
1209
- if (dynamicSize && delta !== 0) {
1210
- actualScrollSize = scrollSize + delta;
1211
- }
1296
+ const scrollSize = (this._isVertical ? container.scrollTop : container.scrollLeft), actualScrollSize = scrollSize;
1212
1297
  this._scrollSize.set(actualScrollSize);
1213
1298
  }
1214
1299
  };
@@ -1254,7 +1339,7 @@ class NgVirtualListComponent {
1254
1339
  const { width, height } = bounds;
1255
1340
  let actualScrollSize = (this._isVertical ? this._container()?.nativeElement.scrollTop ?? 0 : this._container()?.nativeElement.scrollLeft) ?? 0;
1256
1341
  const opts = {
1257
- bounds: { width, height }, collection: items, dynamicSize, isVertical, itemSize,
1342
+ bounds: { width, height }, dynamicSize, isVertical, itemSize,
1258
1343
  itemsOffset, scrollSize: scrollSize, snap, enabledBufferOptimization,
1259
1344
  };
1260
1345
  const { displayItems, totalSize } = this._trackBox.updateCollection(items, stickyMap, {
@@ -1265,28 +1350,15 @@ class NgVirtualListComponent {
1265
1350
  this.tracking();
1266
1351
  const container = this._container();
1267
1352
  if (container) {
1268
- actualScrollSize = actualScrollSize + this._trackBox.delta;
1353
+ const delta = this._trackBox.delta;
1354
+ actualScrollSize = actualScrollSize + delta;
1269
1355
  this._trackBox.clearDelta();
1270
- if (dynamicSize) {
1271
- if (scrollSize !== actualScrollSize) {
1272
- const params = {
1273
- [this._isVertical ? TOP_PROP_NAME : LEFT_PROP_NAME]: actualScrollSize,
1274
- behavior: BEHAVIOR_INSTANT
1275
- };
1276
- container.nativeElement.scrollTo(params);
1277
- }
1278
- }
1279
- else {
1280
- if (scrollSize !== actualScrollSize) {
1281
- const params = {
1282
- [this._isVertical ? TOP_PROP_NAME : LEFT_PROP_NAME]: actualScrollSize,
1283
- behavior: BEHAVIOR_INSTANT
1284
- };
1285
- const container = this._container();
1286
- if (container) {
1287
- container.nativeElement.scrollTo(params);
1288
- }
1289
- }
1356
+ if (scrollSize !== actualScrollSize) {
1357
+ const params = {
1358
+ [this._isVertical ? TOP_PROP_NAME : LEFT_PROP_NAME]: actualScrollSize,
1359
+ behavior: BEHAVIOR_INSTANT
1360
+ };
1361
+ container.nativeElement.scrollTo(params);
1290
1362
  }
1291
1363
  }
1292
1364
  return of(displayItems);