ng-virtual-list 18.3.2 → 18.4.0
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 +9 -8
- package/esm2022/lib/components/ng-virtual-list-item.component.mjs +2 -2
- package/esm2022/lib/const/index.mjs +3 -2
- package/esm2022/lib/ng-virtual-list.component.mjs +35 -9
- package/esm2022/lib/utils/buffer-interpolation.mjs +27 -0
- package/esm2022/lib/utils/trackBox.mjs +49 -10
- package/fesm2022/ng-virtual-list.mjs +111 -19
- package/fesm2022/ng-virtual-list.mjs.map +1 -1
- package/lib/const/index.d.ts +2 -1
- package/lib/ng-virtual-list.component.d.ts +14 -1
- package/lib/utils/buffer-interpolation.d.ts +5 -0
- package/lib/utils/trackBox.d.ts +16 -1
- package/package.json +1 -1
|
@@ -42,7 +42,8 @@ var SnappingMethods;
|
|
|
42
42
|
})(SnappingMethods || (SnappingMethods = {}));
|
|
43
43
|
|
|
44
44
|
const DEFAULT_ITEM_SIZE = 24;
|
|
45
|
-
const
|
|
45
|
+
const DEFAULT_BUFFER_SIZE = 2;
|
|
46
|
+
const DEFAULT_MAX_BUFFER_SIZE = 100;
|
|
46
47
|
const DEFAULT_LIST_SIZE = 400;
|
|
47
48
|
const DEFAULT_SNAP = false;
|
|
48
49
|
const DEFAULT_ENABLED_BUFFER_OPTIMIZATION = false;
|
|
@@ -209,13 +210,13 @@ class NgVirtualListItemComponent extends BaseVirtualListItemComponent {
|
|
|
209
210
|
styles.zIndex = HIDDEN_ZINDEX;
|
|
210
211
|
}
|
|
211
212
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NgVirtualListItemComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
212
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.13", type: NgVirtualListItemComponent, selector: "ng-virtual-list-item", host: { classAttribute: "ngvl__item" }, usesInheritance: true, ngImport: i0, template: "@let item = data();\r\n@let renderer = itemRenderer();\r\n\r\n@if (item) {\r\n <li #listItem part=\"item\" class=\"ngvl-item__container\" [ngClass]=\"{'snapped': item.config.snapped,\r\n 'snapped-out': item.config.snappedOut}\">\r\n @if (renderer) {\r\n <ng-container [ngTemplateOutlet]=\"renderer\"\r\n [ngTemplateOutletContext]=\"{data: item.data || {}, config: item.config}\" />\r\n }\r\n </li>\r\n}", styles: [":host{display:block;position:absolute;left:0;top:0;box-sizing:border-box;overflow:hidden
|
|
213
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.13", type: NgVirtualListItemComponent, selector: "ng-virtual-list-item", host: { classAttribute: "ngvl__item" }, usesInheritance: true, ngImport: i0, template: "@let item = data();\r\n@let renderer = itemRenderer();\r\n\r\n@if (item) {\r\n <li #listItem part=\"item\" class=\"ngvl-item__container\" [ngClass]=\"{'snapped': item.config.snapped,\r\n 'snapped-out': item.config.snappedOut}\">\r\n @if (renderer) {\r\n <ng-container [ngTemplateOutlet]=\"renderer\"\r\n [ngTemplateOutletContext]=\"{data: item.data || {}, config: item.config}\" />\r\n }\r\n </li>\r\n}", styles: [":host{display:block;position:absolute;left:0;top:0;box-sizing:border-box;overflow:hidden}.ngvl-item__container{margin:0;padding:0;overflow:hidden;background-color:#fff;width:inherit;height:inherit}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
213
214
|
}
|
|
214
215
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NgVirtualListItemComponent, decorators: [{
|
|
215
216
|
type: Component,
|
|
216
217
|
args: [{ selector: 'ng-virtual-list-item', standalone: false, host: {
|
|
217
218
|
'class': 'ngvl__item',
|
|
218
|
-
}, changeDetection: ChangeDetectionStrategy.OnPush, template: "@let item = data();\r\n@let renderer = itemRenderer();\r\n\r\n@if (item) {\r\n <li #listItem part=\"item\" class=\"ngvl-item__container\" [ngClass]=\"{'snapped': item.config.snapped,\r\n 'snapped-out': item.config.snappedOut}\">\r\n @if (renderer) {\r\n <ng-container [ngTemplateOutlet]=\"renderer\"\r\n [ngTemplateOutletContext]=\"{data: item.data || {}, config: item.config}\" />\r\n }\r\n </li>\r\n}", styles: [":host{display:block;position:absolute;left:0;top:0;box-sizing:border-box;overflow:hidden
|
|
219
|
+
}, changeDetection: ChangeDetectionStrategy.OnPush, template: "@let item = data();\r\n@let renderer = itemRenderer();\r\n\r\n@if (item) {\r\n <li #listItem part=\"item\" class=\"ngvl-item__container\" [ngClass]=\"{'snapped': item.config.snapped,\r\n 'snapped-out': item.config.snappedOut}\">\r\n @if (renderer) {\r\n <ng-container [ngTemplateOutlet]=\"renderer\"\r\n [ngTemplateOutletContext]=\"{data: item.data || {}, config: item.config}\" />\r\n }\r\n </li>\r\n}", styles: [":host{display:block;position:absolute;left:0;top:0;box-sizing:border-box;overflow:hidden}.ngvl-item__container{margin:0;padding:0;overflow:hidden;background-color:#fff;width:inherit;height:inherit}\n"] }]
|
|
219
220
|
}], ctorParameters: () => [] });
|
|
220
221
|
|
|
221
222
|
const HORIZONTAL_ALIASES = [Directions.HORIZONTAL, 'horizontal'], VERTICAL_ALIASES = [Directions.VERTICAL, 'vertical'];
|
|
@@ -684,6 +685,33 @@ class CacheMap extends EventEmitter {
|
|
|
684
685
|
}
|
|
685
686
|
}
|
|
686
687
|
|
|
688
|
+
const DEFAULT_EXTRA = {
|
|
689
|
+
extremumThreshold: 2,
|
|
690
|
+
bufferSize: 10,
|
|
691
|
+
};
|
|
692
|
+
const bufferInterpolation = (currentBufferValue, array, value, extra) => {
|
|
693
|
+
const { extremumThreshold = DEFAULT_EXTRA.extremumThreshold, bufferSize = DEFAULT_EXTRA.bufferSize, } = extra ?? DEFAULT_EXTRA;
|
|
694
|
+
if (currentBufferValue < value) {
|
|
695
|
+
let i = 0;
|
|
696
|
+
while (i < extremumThreshold) {
|
|
697
|
+
array.push(value);
|
|
698
|
+
i++;
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
else {
|
|
702
|
+
array.push(value);
|
|
703
|
+
}
|
|
704
|
+
while (array.length >= bufferSize) {
|
|
705
|
+
array.shift();
|
|
706
|
+
}
|
|
707
|
+
const l = array.length;
|
|
708
|
+
let buffer = 0;
|
|
709
|
+
for (let i = 0; i < l; i++) {
|
|
710
|
+
buffer += array[i];
|
|
711
|
+
}
|
|
712
|
+
return Math.ceil(buffer / l);
|
|
713
|
+
};
|
|
714
|
+
|
|
687
715
|
const TRACK_BOX_CHANGE_EVENT_NAME = 'change';
|
|
688
716
|
var ItemDisplayMethods;
|
|
689
717
|
(function (ItemDisplayMethods) {
|
|
@@ -692,6 +720,7 @@ var ItemDisplayMethods;
|
|
|
692
720
|
ItemDisplayMethods[ItemDisplayMethods["DELETE"] = 2] = "DELETE";
|
|
693
721
|
ItemDisplayMethods[ItemDisplayMethods["NOT_CHANGED"] = 3] = "NOT_CHANGED";
|
|
694
722
|
})(ItemDisplayMethods || (ItemDisplayMethods = {}));
|
|
723
|
+
const DEFAULT_BUFFER_EXTREMUM_THRESHOLD = 15, DEFAULT_MAX_BUFFER_SEQUENCE_LENGTH = 30, DEFAULT_RESET_BUFFER_SIZE_TIMEOUT = 10000;
|
|
695
724
|
/**
|
|
696
725
|
* An object that performs tracking, calculations and caching.
|
|
697
726
|
* @link https://github.com/DjonnyX/ng-virtual-list/blob/18.x/projects/ng-virtual-list/src/lib/utils/trackBox.ts
|
|
@@ -761,6 +790,16 @@ class TrackBox extends CacheMap {
|
|
|
761
790
|
_previousTotalSize = 0;
|
|
762
791
|
_scrollDelta = 0;
|
|
763
792
|
get scrollDelta() { return this._scrollDelta; }
|
|
793
|
+
isAdaptiveBuffer = true;
|
|
794
|
+
_bufferSequenceExtraThreshold = DEFAULT_BUFFER_EXTREMUM_THRESHOLD;
|
|
795
|
+
_maxBufferSequenceLength = DEFAULT_MAX_BUFFER_SEQUENCE_LENGTH;
|
|
796
|
+
_bufferSizeSequence = [];
|
|
797
|
+
_bufferSize = 0;
|
|
798
|
+
get bufferSize() { return this._bufferSize; }
|
|
799
|
+
_defaultBufferSize = 0;
|
|
800
|
+
_maxBufferSize = this._defaultBufferSize;
|
|
801
|
+
_resetBufferSizeTimeout = DEFAULT_RESET_BUFFER_SIZE_TIMEOUT;
|
|
802
|
+
_resetBufferSizeTimer;
|
|
764
803
|
lifeCircle() {
|
|
765
804
|
this.fireChangeIfNeed();
|
|
766
805
|
this.lifeCircleDo();
|
|
@@ -854,6 +893,8 @@ class TrackBox extends CacheMap {
|
|
|
854
893
|
*/
|
|
855
894
|
getItemPosition(id, stickyMap, options) {
|
|
856
895
|
const opt = { fromItemId: id, stickyMap, ...options };
|
|
896
|
+
this._defaultBufferSize = opt.bufferSize;
|
|
897
|
+
this._maxBufferSize = opt.maxBufferSize;
|
|
857
898
|
const { scrollSize, isFromItemIdFound } = this.recalculateMetrics({
|
|
858
899
|
...opt,
|
|
859
900
|
dynamicSize: this._crudDetected || opt.dynamicSize,
|
|
@@ -871,6 +912,8 @@ class TrackBox extends CacheMap {
|
|
|
871
912
|
if (opt.dynamicSize) {
|
|
872
913
|
this.cacheElements();
|
|
873
914
|
}
|
|
915
|
+
this._defaultBufferSize = opt.bufferSize;
|
|
916
|
+
this._maxBufferSize = opt.maxBufferSize;
|
|
874
917
|
const metrics = this.recalculateMetrics({
|
|
875
918
|
...opt,
|
|
876
919
|
collection: items,
|
|
@@ -879,6 +922,7 @@ class TrackBox extends CacheMap {
|
|
|
879
922
|
deletedItemsMap,
|
|
880
923
|
});
|
|
881
924
|
this._delta += metrics.delta;
|
|
925
|
+
this.updateAdaptiveBufferParams(metrics, items.length);
|
|
882
926
|
this._previousTotalSize = metrics.totalSize;
|
|
883
927
|
this._deletedItemsMap = {};
|
|
884
928
|
this._crudDetected = false;
|
|
@@ -894,6 +938,27 @@ class TrackBox extends CacheMap {
|
|
|
894
938
|
getNearestItem(scrollSize, items, itemSize, isVertical) {
|
|
895
939
|
return this.getElementFromStart(scrollSize, items, this._map, itemSize, isVertical);
|
|
896
940
|
}
|
|
941
|
+
_previousScrollSize = 0;
|
|
942
|
+
updateAdaptiveBufferParams(metrics, totalItemsLength) {
|
|
943
|
+
this.disposeClearBufferSizeTimer();
|
|
944
|
+
const scrollSize = metrics.scrollSize + this._delta, delta = Math.abs(this._previousScrollSize - scrollSize);
|
|
945
|
+
this._previousScrollSize = scrollSize;
|
|
946
|
+
const bufferRawSize = Math.min(Math.floor(delta / metrics.typicalItemSize) * 5, totalItemsLength), minBufferSize = bufferRawSize < this._defaultBufferSize ? this._defaultBufferSize : bufferRawSize, bufferValue = minBufferSize > this._maxBufferSize ? this._maxBufferSize : minBufferSize;
|
|
947
|
+
this._bufferSize = bufferInterpolation(this._bufferSize, this._bufferSizeSequence, bufferValue, {
|
|
948
|
+
extremumThreshold: this._bufferSequenceExtraThreshold,
|
|
949
|
+
bufferSize: this._maxBufferSequenceLength,
|
|
950
|
+
});
|
|
951
|
+
this.startResetBufferSizeTimer();
|
|
952
|
+
}
|
|
953
|
+
startResetBufferSizeTimer() {
|
|
954
|
+
this._resetBufferSizeTimer = setTimeout(() => {
|
|
955
|
+
this._bufferSize = this._defaultBufferSize;
|
|
956
|
+
this._bufferSizeSequence = [];
|
|
957
|
+
}, this._resetBufferSizeTimeout);
|
|
958
|
+
}
|
|
959
|
+
disposeClearBufferSizeTimer() {
|
|
960
|
+
clearTimeout(this._resetBufferSizeTimer);
|
|
961
|
+
}
|
|
897
962
|
/**
|
|
898
963
|
* Calculates the position of an element based on the given scrollSize
|
|
899
964
|
*/
|
|
@@ -945,30 +1010,30 @@ class TrackBox extends CacheMap {
|
|
|
945
1010
|
* Calculates list metrics
|
|
946
1011
|
*/
|
|
947
1012
|
recalculateMetrics(options) {
|
|
948
|
-
const { fromItemId, bounds, collection, dynamicSize, isVertical, itemSize,
|
|
949
|
-
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)
|
|
1013
|
+
const { fromItemId, bounds, collection, dynamicSize, isVertical, itemSize, bufferSize: minBufferSize, scrollSize, snap, stickyMap, enabledBufferOptimization, previousTotalSize, crudDetected, deletedItemsMap } = options;
|
|
1014
|
+
const bufferSize = Math.max(minBufferSize, this._bufferSize), { 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)
|
|
950
1015
|
|| (typeof fromItemId === 'string' && fromItemId > '-1');
|
|
951
1016
|
let leftItemsOffset = 0, rightItemsOffset = 0;
|
|
952
1017
|
if (enabledBufferOptimization) {
|
|
953
1018
|
switch (this.scrollDirection) {
|
|
954
1019
|
case 1: {
|
|
955
1020
|
leftItemsOffset = 0;
|
|
956
|
-
rightItemsOffset =
|
|
1021
|
+
rightItemsOffset = bufferSize;
|
|
957
1022
|
break;
|
|
958
1023
|
}
|
|
959
1024
|
case -1: {
|
|
960
|
-
leftItemsOffset =
|
|
1025
|
+
leftItemsOffset = bufferSize;
|
|
961
1026
|
rightItemsOffset = 0;
|
|
962
1027
|
break;
|
|
963
1028
|
}
|
|
964
1029
|
case 0:
|
|
965
1030
|
default: {
|
|
966
|
-
leftItemsOffset = rightItemsOffset =
|
|
1031
|
+
leftItemsOffset = rightItemsOffset = bufferSize;
|
|
967
1032
|
}
|
|
968
1033
|
}
|
|
969
1034
|
}
|
|
970
1035
|
else {
|
|
971
|
-
leftItemsOffset = rightItemsOffset =
|
|
1036
|
+
leftItemsOffset = rightItemsOffset = bufferSize;
|
|
972
1037
|
}
|
|
973
1038
|
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, isFromItemIdFound = false;
|
|
974
1039
|
// If the list is dynamic or there are new elements in the collection, then it switches to the long algorithm.
|
|
@@ -1143,9 +1208,9 @@ class TrackBox extends CacheMap {
|
|
|
1143
1208
|
}
|
|
1144
1209
|
itemsFromStartToScrollEnd = Math.floor(scrollSize / typicalItemSize);
|
|
1145
1210
|
itemsFromStartToDisplayEnd = Math.ceil((scrollSize + size) / typicalItemSize);
|
|
1146
|
-
leftItemLength = Math.min(itemsFromStartToScrollEnd,
|
|
1147
|
-
rightItemLength = itemsFromStartToDisplayEnd +
|
|
1148
|
-
? totalLength - itemsFromStartToDisplayEnd :
|
|
1211
|
+
leftItemLength = Math.min(itemsFromStartToScrollEnd, bufferSize);
|
|
1212
|
+
rightItemLength = itemsFromStartToDisplayEnd + bufferSize > totalLength
|
|
1213
|
+
? totalLength - itemsFromStartToDisplayEnd : bufferSize;
|
|
1149
1214
|
leftItemsWeight = leftItemLength * typicalItemSize;
|
|
1150
1215
|
rightItemsWeight = rightItemLength * typicalItemSize;
|
|
1151
1216
|
leftHiddenItemsWeight = itemsFromStartToScrollEnd * typicalItemSize;
|
|
@@ -1390,6 +1455,7 @@ class TrackBox extends CacheMap {
|
|
|
1390
1455
|
}
|
|
1391
1456
|
dispose() {
|
|
1392
1457
|
super.dispose();
|
|
1458
|
+
this.disposeClearBufferSizeTimer();
|
|
1393
1459
|
if (this._tracker) {
|
|
1394
1460
|
this._tracker.dispose();
|
|
1395
1461
|
}
|
|
@@ -1533,10 +1599,35 @@ class NgVirtualListComponent {
|
|
|
1533
1599
|
* Determines the direction in which elements are placed. Default value is "vertical".
|
|
1534
1600
|
*/
|
|
1535
1601
|
direction = input(DEFAULT_DIRECTION);
|
|
1602
|
+
_itemOffsetTransform = {
|
|
1603
|
+
transform: (v) => {
|
|
1604
|
+
throw Error('"itemOffset" parameter is deprecated. Use "bufferSize" and "maxBufferSize".');
|
|
1605
|
+
}
|
|
1606
|
+
};
|
|
1607
|
+
/**
|
|
1608
|
+
* Number of elements outside the scope of visibility. Default value is 2.
|
|
1609
|
+
* @deprecated "itemOffset" parameter is deprecated. Use "bufferSize" and "maxBufferSize".
|
|
1610
|
+
*/
|
|
1611
|
+
itemsOffset = input(DEFAULT_BUFFER_SIZE, { ...this._itemOffsetTransform });
|
|
1536
1612
|
/**
|
|
1537
1613
|
* Number of elements outside the scope of visibility. Default value is 2.
|
|
1538
1614
|
*/
|
|
1539
|
-
|
|
1615
|
+
bufferSize = input(DEFAULT_BUFFER_SIZE);
|
|
1616
|
+
_maxBufferSizeTransform = {
|
|
1617
|
+
transform: (v) => {
|
|
1618
|
+
const bufferSize = this.bufferSize();
|
|
1619
|
+
if (v === undefined || v <= bufferSize) {
|
|
1620
|
+
return bufferSize;
|
|
1621
|
+
}
|
|
1622
|
+
return v;
|
|
1623
|
+
}
|
|
1624
|
+
};
|
|
1625
|
+
/**
|
|
1626
|
+
* Maximum number of elements outside the scope of visibility. Default value is 100.
|
|
1627
|
+
* If maxBufferSize is set to be greater than bufferSize, then adaptive buffer mode is enabled.
|
|
1628
|
+
* The greater the scroll size, the more elements are allocated for rendering.
|
|
1629
|
+
*/
|
|
1630
|
+
maxBufferSize = input(DEFAULT_MAX_BUFFER_SIZE, { ...this._maxBufferSizeTransform });
|
|
1540
1631
|
/**
|
|
1541
1632
|
* Snapping method.
|
|
1542
1633
|
* 'default' - Normal group rendering.
|
|
@@ -1640,7 +1731,7 @@ class NgVirtualListComponent {
|
|
|
1640
1731
|
$trackBy.pipe(takeUntilDestroyed(), tap(v => {
|
|
1641
1732
|
this._trackBox.trackingPropertyName = v;
|
|
1642
1733
|
})).subscribe();
|
|
1643
|
-
const $bounds = toObservable(this._bounds).pipe(filter(b => !!b)), $items = toObservable(this.items).pipe(map(i => !i ? [] : i)), $scrollSize = toObservable(this._scrollSize), $itemSize = toObservable(this.itemSize).pipe(map(v => v <= 0 ? DEFAULT_ITEM_SIZE : v)), $
|
|
1734
|
+
const $bounds = toObservable(this._bounds).pipe(filter(b => !!b)), $items = toObservable(this.items).pipe(map(i => !i ? [] : i)), $scrollSize = toObservable(this._scrollSize), $itemSize = toObservable(this.itemSize).pipe(map(v => v <= 0 ? DEFAULT_ITEM_SIZE : v)), $bufferSize = toObservable(this.bufferSize).pipe(map(v => v < 0 ? DEFAULT_BUFFER_SIZE : v)), $maxBufferSize = toObservable(this.maxBufferSize).pipe(map(v => v < 0 ? DEFAULT_BUFFER_SIZE : v)), $stickyMap = toObservable(this.stickyMap).pipe(map(v => !v ? {} : v)), $snap = toObservable(this.snap), $isVertical = toObservable(this.direction).pipe(map(v => this.getIsVertical(v || DEFAULT_DIRECTION))), $dynamicSize = toObservable(this.dynamicSize), $enabledBufferOptimization = toObservable(this.enabledBufferOptimization), $snappingMethod = toObservable(this.snappingMethod).pipe(map(v => this.getIsSnappingMethodAdvanced(v || DEFAULT_SNAPPING_METHOD))), $cacheVersion = toObservable(this._cacheVersion);
|
|
1644
1735
|
$isVertical.pipe(takeUntilDestroyed(), tap(v => {
|
|
1645
1736
|
this._isVertical = v;
|
|
1646
1737
|
const el = this._elementRef.nativeElement;
|
|
@@ -1653,12 +1744,12 @@ class NgVirtualListComponent {
|
|
|
1653
1744
|
this.listenCacheChangesIfNeed(dynamicSize);
|
|
1654
1745
|
})).subscribe();
|
|
1655
1746
|
combineLatest([this.$initialized, $bounds, $items, $stickyMap, $scrollSize, $itemSize,
|
|
1656
|
-
$
|
|
1657
|
-
]).pipe(takeUntilDestroyed(), distinctUntilChanged(), filter(([initialized]) => !!initialized), switchMap(([, bounds, items, stickyMap, scrollSize, itemSize,
|
|
1747
|
+
$bufferSize, $maxBufferSize, $snap, $isVertical, $dynamicSize, $enabledBufferOptimization, $cacheVersion,
|
|
1748
|
+
]).pipe(takeUntilDestroyed(), distinctUntilChanged(), filter(([initialized]) => !!initialized), switchMap(([, bounds, items, stickyMap, scrollSize, itemSize, bufferSize, maxBufferSize, snap, isVertical, dynamicSize, enabledBufferOptimization, cacheVersion,]) => {
|
|
1658
1749
|
let actualScrollSize = (this._isVertical ? this._container()?.nativeElement.scrollTop ?? 0 : this._container()?.nativeElement.scrollLeft) ?? 0;
|
|
1659
1750
|
const { width, height } = bounds, opts = {
|
|
1660
1751
|
bounds: { width, height }, dynamicSize, isVertical, itemSize,
|
|
1661
|
-
|
|
1752
|
+
bufferSize, maxBufferSize, scrollSize: actualScrollSize, snap, enabledBufferOptimization,
|
|
1662
1753
|
}, { displayItems, totalSize } = this._trackBox.updateCollection(items, stickyMap, opts);
|
|
1663
1754
|
this.resetBoundsSize(isVertical, totalSize);
|
|
1664
1755
|
this.createDisplayComponentsIfNeed(displayItems);
|
|
@@ -1805,7 +1896,8 @@ class NgVirtualListComponent {
|
|
|
1805
1896
|
}
|
|
1806
1897
|
const { width, height } = this._bounds() || { width: DEFAULT_LIST_SIZE, height: DEFAULT_LIST_SIZE }, stickyMap = this.stickyMap(), items = this.items(), isVertical = this._isVertical, delta = this._trackBox.delta, opts = {
|
|
1807
1898
|
bounds: { width, height }, collection: items, dynamicSize, isVertical: this._isVertical, itemSize,
|
|
1808
|
-
|
|
1899
|
+
bufferSize: this.bufferSize(), maxBufferSize: this.maxBufferSize(),
|
|
1900
|
+
scrollSize: (isVertical ? container.nativeElement.scrollTop : container.nativeElement.scrollLeft) + delta,
|
|
1809
1901
|
snap: this.snap(), fromItemId: id, enabledBufferOptimization: this.enabledBufferOptimization(),
|
|
1810
1902
|
}, scrollSize = this._trackBox.getItemPosition(id, stickyMap, opts), params = { [isVertical ? TOP_PROP_NAME : LEFT_PROP_NAME]: scrollSize, behavior };
|
|
1811
1903
|
if (scrollSize === -1) {
|
|
@@ -1936,7 +2028,7 @@ class NgVirtualListComponent {
|
|
|
1936
2028
|
}
|
|
1937
2029
|
}
|
|
1938
2030
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NgVirtualListComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1939
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.13", type: NgVirtualListComponent, selector: "ng-virtual-list", inputs: { items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: true, transformFunction: null }, snap: { classPropertyName: "snap", publicName: "snap", isSignal: true, isRequired: false, transformFunction: null }, enabledBufferOptimization: { classPropertyName: "enabledBufferOptimization", publicName: "enabledBufferOptimization", isSignal: true, isRequired: false, transformFunction: null }, itemRenderer: { classPropertyName: "itemRenderer", publicName: "itemRenderer", isSignal: true, isRequired: true, transformFunction: null }, stickyMap: { classPropertyName: "stickyMap", publicName: "stickyMap", isSignal: true, isRequired: false, transformFunction: null }, itemSize: { classPropertyName: "itemSize", publicName: "itemSize", isSignal: true, isRequired: false, transformFunction: null }, dynamicSize: { classPropertyName: "dynamicSize", publicName: "dynamicSize", isSignal: true, isRequired: false, transformFunction: null }, direction: { classPropertyName: "direction", publicName: "direction", isSignal: true, isRequired: false, transformFunction: null }, itemsOffset: { classPropertyName: "itemsOffset", publicName: "itemsOffset", isSignal: true, isRequired: false, transformFunction: null }, snappingMethod: { classPropertyName: "snappingMethod", publicName: "snappingMethod", isSignal: true, isRequired: false, transformFunction: null }, trackBy: { classPropertyName: "trackBy", publicName: "trackBy", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onScroll: "onScroll", onScrollEnd: "onScrollEnd" }, viewQueries: [{ propertyName: "_snappedContainer", first: true, predicate: ["snapped"], descendants: true, isSignal: true }, { propertyName: "_container", first: true, predicate: ["container"], descendants: true, isSignal: true }, { propertyName: "_list", first: true, predicate: ["list"], descendants: true, isSignal: true }, { propertyName: "_listContainerRef", first: true, predicate: ["renderersContainer"], descendants: true, read: ViewContainerRef }, { propertyName: "_snapContainerRef", first: true, predicate: ["snapRendererContainer"], descendants: true, read: ViewContainerRef }], ngImport: i0, template: "@if (snap()) {\r\n<div #snapped part=\"snapped-item\" class=\"ngvl__list-snapper\">\r\n <ng-container #snapRendererContainer></ng-container>\r\n</div>\r\n}\r\n<div #container part=\"scroller\" class=\"ngvl__scroller\">\r\n <ul #list part=\"list\" class=\"ngvl__list\">\r\n <ng-container #renderersContainer></ng-container>\r\n </ul>\r\n</div>", styles: [":host{position:relative;display:block;width:400px;overflow:hidden}:host(.horizontal){height:48px}:host(.horizontal) .ngvl__list{display:inline-flex}:host(.horizontal) .ngvl__scroller{overflow:auto hidden}:host(.vertical) .ngvl__scroller{overflow:hidden auto}:host(.vertical){height:320px}.ngvl__scroller{overflow:auto;width:100%;height:100%}.ngvl__list-snapper{pointer-events:none;position:absolute;list-style:none;left:0;top:0;z-index:1}.ngvl__list{position:relative;list-style:none;padding:0;margin:0;width:100%;height:100%}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.ShadowDom });
|
|
2031
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.13", type: NgVirtualListComponent, selector: "ng-virtual-list", inputs: { items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: true, transformFunction: null }, snap: { classPropertyName: "snap", publicName: "snap", isSignal: true, isRequired: false, transformFunction: null }, enabledBufferOptimization: { classPropertyName: "enabledBufferOptimization", publicName: "enabledBufferOptimization", isSignal: true, isRequired: false, transformFunction: null }, itemRenderer: { classPropertyName: "itemRenderer", publicName: "itemRenderer", isSignal: true, isRequired: true, transformFunction: null }, stickyMap: { classPropertyName: "stickyMap", publicName: "stickyMap", isSignal: true, isRequired: false, transformFunction: null }, itemSize: { classPropertyName: "itemSize", publicName: "itemSize", isSignal: true, isRequired: false, transformFunction: null }, dynamicSize: { classPropertyName: "dynamicSize", publicName: "dynamicSize", isSignal: true, isRequired: false, transformFunction: null }, direction: { classPropertyName: "direction", publicName: "direction", isSignal: true, isRequired: false, transformFunction: null }, itemsOffset: { classPropertyName: "itemsOffset", publicName: "itemsOffset", isSignal: true, isRequired: false, transformFunction: null }, bufferSize: { classPropertyName: "bufferSize", publicName: "bufferSize", isSignal: true, isRequired: false, transformFunction: null }, maxBufferSize: { classPropertyName: "maxBufferSize", publicName: "maxBufferSize", isSignal: true, isRequired: false, transformFunction: null }, snappingMethod: { classPropertyName: "snappingMethod", publicName: "snappingMethod", isSignal: true, isRequired: false, transformFunction: null }, trackBy: { classPropertyName: "trackBy", publicName: "trackBy", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onScroll: "onScroll", onScrollEnd: "onScrollEnd" }, viewQueries: [{ propertyName: "_snappedContainer", first: true, predicate: ["snapped"], descendants: true, isSignal: true }, { propertyName: "_container", first: true, predicate: ["container"], descendants: true, isSignal: true }, { propertyName: "_list", first: true, predicate: ["list"], descendants: true, isSignal: true }, { propertyName: "_listContainerRef", first: true, predicate: ["renderersContainer"], descendants: true, read: ViewContainerRef }, { propertyName: "_snapContainerRef", first: true, predicate: ["snapRendererContainer"], descendants: true, read: ViewContainerRef }], ngImport: i0, template: "@if (snap()) {\r\n<div #snapped part=\"snapped-item\" class=\"ngvl__list-snapper\">\r\n <ng-container #snapRendererContainer></ng-container>\r\n</div>\r\n}\r\n<div #container part=\"scroller\" class=\"ngvl__scroller\">\r\n <ul #list part=\"list\" class=\"ngvl__list\">\r\n <ng-container #renderersContainer></ng-container>\r\n </ul>\r\n</div>", styles: [":host{position:relative;display:block;width:400px;overflow:hidden}:host(.horizontal){height:48px}:host(.horizontal) .ngvl__list{display:inline-flex}:host(.horizontal) .ngvl__scroller{overflow:auto hidden}:host(.vertical) .ngvl__scroller{overflow:hidden auto}:host(.vertical){height:320px}.ngvl__scroller{overflow:auto;width:100%;height:100%}.ngvl__list-snapper{pointer-events:none;position:absolute;list-style:none;left:0;top:0;z-index:1}.ngvl__list{position:relative;list-style:none;padding:0;margin:0;width:100%;height:100%}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.ShadowDom });
|
|
1940
2032
|
}
|
|
1941
2033
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NgVirtualListComponent, decorators: [{
|
|
1942
2034
|
type: Component,
|