ng-virtual-list 14.7.12 → 14.7.13
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/esm2020/lib/const/index.mjs +3 -2
- package/esm2020/lib/enums/collection-mode.mjs +2 -0
- package/esm2020/lib/enums/collection-modes.mjs +18 -0
- package/esm2020/lib/enums/index.mjs +3 -2
- package/esm2020/lib/ng-virtual-list.component.mjs +63 -14
- package/esm2020/lib/utils/isCollectionMode.mjs +15 -0
- package/esm2020/lib/utils/trackBox.mjs +45 -16
- package/fesm2015/ng-virtual-list.mjs +142 -31
- package/fesm2015/ng-virtual-list.mjs.map +1 -1
- package/fesm2020/ng-virtual-list.mjs +136 -26
- package/fesm2020/ng-virtual-list.mjs.map +1 -1
- package/lib/const/index.d.ts +2 -1
- package/lib/enums/collection-mode.d.ts +8 -0
- package/lib/enums/collection-modes.d.ts +16 -0
- package/lib/enums/index.d.ts +4 -2
- package/lib/ng-virtual-list.component.d.ts +14 -2
- package/lib/utils/isCollectionMode.d.ts +8 -0
- package/lib/utils/trackBox.d.ts +17 -9
- package/package.json +1 -1
|
@@ -1,11 +1,29 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { Injectable, Component, ChangeDetectionStrategy, EventEmitter as EventEmitter$1, ViewContainerRef, ElementRef, ViewEncapsulation, ViewChild, Output, Input, NgModule, NO_ERRORS_SCHEMA } from '@angular/core';
|
|
3
3
|
import { takeUntil as takeUntil$1, tap as tap$1, map } from 'rxjs/operators';
|
|
4
|
-
import { Subject, takeUntil, tap, BehaviorSubject as BehaviorSubject$1, fromEvent, combineLatest, filter, distinctUntilChanged,
|
|
4
|
+
import { Subject, takeUntil, tap, BehaviorSubject as BehaviorSubject$1, fromEvent, combineLatest, filter, distinctUntilChanged, map as map$1, debounceTime, switchMap, of } from 'rxjs';
|
|
5
5
|
import { BehaviorSubject } from 'rxjs/internal/BehaviorSubject';
|
|
6
6
|
import * as i2 from '@angular/common';
|
|
7
7
|
import { CommonModule } from '@angular/common';
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Action modes for collection elements.
|
|
11
|
+
* @link https://github.com/DjonnyX/ng-virtual-list/blob/14.x/projects/ng-virtual-list/src/lib/enums/collection-modes.ts
|
|
12
|
+
* @author Evgenii Grebennikov
|
|
13
|
+
* @email djonnyx@gmail.com
|
|
14
|
+
*/
|
|
15
|
+
var CollectionModes;
|
|
16
|
+
(function (CollectionModes) {
|
|
17
|
+
/**
|
|
18
|
+
* When adding elements to the beginning of the collection, the scroll remains at the current position.
|
|
19
|
+
*/
|
|
20
|
+
CollectionModes["NORMAL"] = "normal";
|
|
21
|
+
/**
|
|
22
|
+
* When adding elements to the beginning of the collection, the scroll is shifted by the sum of the sizes of the new elements.
|
|
23
|
+
*/
|
|
24
|
+
CollectionModes["LAZY"] = "lazy";
|
|
25
|
+
})(CollectionModes || (CollectionModes = {}));
|
|
26
|
+
|
|
9
27
|
/**
|
|
10
28
|
* Axis of the arrangement of virtual list elements.
|
|
11
29
|
* @link https://github.com/DjonnyX/ng-virtual-list/blob/14.x/projects/ng-virtual-list/src/lib/enums/directions.ts
|
|
@@ -75,6 +93,7 @@ const DEFAULT_ENABLED_BUFFER_OPTIMIZATION = false;
|
|
|
75
93
|
const DEFAULT_DYNAMIC_SIZE = false;
|
|
76
94
|
const TRACK_BY_PROPERTY_NAME = 'id';
|
|
77
95
|
const DEFAULT_DIRECTION = Directions.VERTICAL;
|
|
96
|
+
const DEFAULT_COLLECTION_MODE = CollectionModes.NORMAL;
|
|
78
97
|
const DISPLAY_OBJECTS_LENGTH_MESUREMENT_ERROR = 1;
|
|
79
98
|
const MAX_SCROLL_TO_ITERATIONS = 5;
|
|
80
99
|
const DEFAULT_SNAPPING_METHOD = SnappingMethods.NORMAL;
|
|
@@ -1265,7 +1284,11 @@ const bufferInterpolation = (currentBufferValue, array, value, extra) => {
|
|
|
1265
1284
|
return Math.ceil(buffer / l);
|
|
1266
1285
|
};
|
|
1267
1286
|
|
|
1268
|
-
|
|
1287
|
+
var TrackBoxEvents;
|
|
1288
|
+
(function (TrackBoxEvents) {
|
|
1289
|
+
TrackBoxEvents["CHANGE"] = "change";
|
|
1290
|
+
TrackBoxEvents["RESET"] = "reset";
|
|
1291
|
+
})(TrackBoxEvents || (TrackBoxEvents = {}));
|
|
1269
1292
|
var ItemDisplayMethods;
|
|
1270
1293
|
(function (ItemDisplayMethods) {
|
|
1271
1294
|
ItemDisplayMethods[ItemDisplayMethods["CREATE"] = 0] = "CREATE";
|
|
@@ -1273,7 +1296,7 @@ var ItemDisplayMethods;
|
|
|
1273
1296
|
ItemDisplayMethods[ItemDisplayMethods["DELETE"] = 2] = "DELETE";
|
|
1274
1297
|
ItemDisplayMethods[ItemDisplayMethods["NOT_CHANGED"] = 3] = "NOT_CHANGED";
|
|
1275
1298
|
})(ItemDisplayMethods || (ItemDisplayMethods = {}));
|
|
1276
|
-
const DEFAULT_BUFFER_EXTREMUM_THRESHOLD = 15, DEFAULT_MAX_BUFFER_SEQUENCE_LENGTH = 30, DEFAULT_RESET_BUFFER_SIZE_TIMEOUT = 10000;
|
|
1299
|
+
const DEFAULT_BUFFER_EXTREMUM_THRESHOLD = 15, DEFAULT_MAX_BUFFER_SEQUENCE_LENGTH = 30, DEFAULT_RESET_BUFFER_SIZE_TIMEOUT = 10000, IS_NEW = 'isNew';
|
|
1277
1300
|
/**
|
|
1278
1301
|
* An object that performs tracking, calculations and caching.
|
|
1279
1302
|
* @link https://github.com/DjonnyX/ng-virtual-list/blob/14.x/projects/ng-virtual-list/src/lib/utils/trackBox.ts
|
|
@@ -1284,6 +1307,7 @@ class TrackBox extends CacheMap {
|
|
|
1284
1307
|
constructor(trackingPropertyName) {
|
|
1285
1308
|
super();
|
|
1286
1309
|
this._isSnappingMethodAdvanced = false;
|
|
1310
|
+
this._isLazy = false;
|
|
1287
1311
|
this._trackingPropertyName = TRACK_BY_PROPERTY_NAME;
|
|
1288
1312
|
this._deletedItemsMap = {};
|
|
1289
1313
|
this._crudDetected = false;
|
|
@@ -1297,7 +1321,7 @@ class TrackBox extends CacheMap {
|
|
|
1297
1321
|
this._defaultBufferSize = 0;
|
|
1298
1322
|
this._maxBufferSize = this._defaultBufferSize;
|
|
1299
1323
|
this._resetBufferSizeTimeout = DEFAULT_RESET_BUFFER_SIZE_TIMEOUT;
|
|
1300
|
-
this.
|
|
1324
|
+
this.isReseted = true;
|
|
1301
1325
|
this._previousScrollSize = 0;
|
|
1302
1326
|
this._trackingPropertyName = trackingPropertyName;
|
|
1303
1327
|
this.initialize();
|
|
@@ -1326,6 +1350,12 @@ class TrackBox extends CacheMap {
|
|
|
1326
1350
|
}
|
|
1327
1351
|
this._isSnappingMethodAdvanced = v;
|
|
1328
1352
|
}
|
|
1353
|
+
set isLazy(v) {
|
|
1354
|
+
if (this._isLazy === v) {
|
|
1355
|
+
return;
|
|
1356
|
+
}
|
|
1357
|
+
this._isLazy = v;
|
|
1358
|
+
}
|
|
1329
1359
|
/**
|
|
1330
1360
|
* Set the trackBy property
|
|
1331
1361
|
*/
|
|
@@ -1349,7 +1379,7 @@ class TrackBox extends CacheMap {
|
|
|
1349
1379
|
get crudDetected() { return this._crudDetected; }
|
|
1350
1380
|
fireChangeIfNeed() {
|
|
1351
1381
|
if (this.changesDetected()) {
|
|
1352
|
-
this.dispatch(
|
|
1382
|
+
this.dispatch(TrackBoxEvents.CHANGE, this._version);
|
|
1353
1383
|
}
|
|
1354
1384
|
}
|
|
1355
1385
|
get scrollDelta() { return this._scrollDelta; }
|
|
@@ -1366,11 +1396,19 @@ class TrackBox extends CacheMap {
|
|
|
1366
1396
|
console.warn('Attention! The collection must be immutable.');
|
|
1367
1397
|
return;
|
|
1368
1398
|
}
|
|
1369
|
-
|
|
1370
|
-
|
|
1399
|
+
let reseted = this.isReseted;
|
|
1400
|
+
if (reseted) {
|
|
1401
|
+
if (!(!this._previousCollection || this._previousCollection.length === 0)) {
|
|
1402
|
+
reseted = false;
|
|
1403
|
+
}
|
|
1371
1404
|
}
|
|
1405
|
+
if (!reseted && (!currentCollection || currentCollection.length === 0)) {
|
|
1406
|
+
reseted = true;
|
|
1407
|
+
}
|
|
1408
|
+
this.isReseted = reseted;
|
|
1409
|
+
this.dispatch(TrackBoxEvents.RESET, reseted);
|
|
1372
1410
|
this.updateCache(this._previousCollection, currentCollection, itemSize);
|
|
1373
|
-
this._previousCollection = currentCollection;
|
|
1411
|
+
this._previousCollection = [...(currentCollection || [])];
|
|
1374
1412
|
}
|
|
1375
1413
|
/**
|
|
1376
1414
|
* Update the cache of items from the list
|
|
@@ -1554,7 +1592,7 @@ class TrackBox extends CacheMap {
|
|
|
1554
1592
|
* Calculates list metrics
|
|
1555
1593
|
*/
|
|
1556
1594
|
recalculateMetrics(options) {
|
|
1557
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1595
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
1558
1596
|
const { fromItemId, bounds, collection, dynamicSize, isVertical, itemSize, bufferSize: minBufferSize, scrollSize, snap, itemConfigMap, enabledBufferOptimization, previousTotalSize, crudDetected, deletedItemsMap } = options;
|
|
1559
1597
|
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)
|
|
1560
1598
|
|| (typeof fromItemId === 'string' && fromItemId > '-1');
|
|
@@ -1581,9 +1619,10 @@ class TrackBox extends CacheMap {
|
|
|
1581
1619
|
leftItemsOffset = rightItemsOffset = bufferSize;
|
|
1582
1620
|
}
|
|
1583
1621
|
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, deltaFromStartCreation = 0;
|
|
1622
|
+
let isNew = !this.isReseted && (scrollSize === 0);
|
|
1584
1623
|
// If the list is dynamic or there are new elements in the collection, then it switches to the long algorithm.
|
|
1585
1624
|
if (dynamicSize) {
|
|
1586
|
-
let y = 0, stickyCollectionItem = undefined, stickyComponentSize = 0
|
|
1625
|
+
let y = 0, stickyCollectionItem = undefined, stickyComponentSize = 0;
|
|
1587
1626
|
for (let i = 0, l = collection.length; i < l; i++) {
|
|
1588
1627
|
const ii = i + 1, collectionItem = collection[i], id = collectionItem.id;
|
|
1589
1628
|
let componentSize = 0, componentSizeDelta = 0, itemDisplayMethod = ItemDisplayMethods.NOT_CHANGED;
|
|
@@ -1591,8 +1630,8 @@ class TrackBox extends CacheMap {
|
|
|
1591
1630
|
const bounds = map.get(id) || { width: typicalItemSize, height: typicalItemSize };
|
|
1592
1631
|
componentSize = bounds[sizeProperty];
|
|
1593
1632
|
itemDisplayMethod = (_a = bounds === null || bounds === void 0 ? void 0 : bounds.method) !== null && _a !== void 0 ? _a : ItemDisplayMethods.UPDATE;
|
|
1594
|
-
const isItemNew = (_b = bounds
|
|
1595
|
-
if (
|
|
1633
|
+
const isItemNew = (_b = bounds === null || bounds === void 0 ? void 0 : bounds[IS_NEW]) !== null && _b !== void 0 ? _b : this._isLazy;
|
|
1634
|
+
if (!isItemNew && (!this._isLazy || !((_c = itemConfigMap[collection[0].id]) === null || _c === void 0 ? void 0 : _c.sticky))) {
|
|
1596
1635
|
isNew = false;
|
|
1597
1636
|
}
|
|
1598
1637
|
switch (itemDisplayMethod) {
|
|
@@ -1614,7 +1653,7 @@ class TrackBox extends CacheMap {
|
|
|
1614
1653
|
}
|
|
1615
1654
|
}
|
|
1616
1655
|
if (deletedItemsMap.hasOwnProperty(i)) {
|
|
1617
|
-
const bounds = deletedItemsMap[i], size = (
|
|
1656
|
+
const bounds = deletedItemsMap[i], size = (_d = bounds === null || bounds === void 0 ? void 0 : bounds[sizeProperty]) !== null && _d !== void 0 ? _d : typicalItemSize;
|
|
1618
1657
|
if (y < scrollSize - size) {
|
|
1619
1658
|
leftSizeOfDeletedItems += size;
|
|
1620
1659
|
}
|
|
@@ -1622,7 +1661,7 @@ class TrackBox extends CacheMap {
|
|
|
1622
1661
|
totalSize += componentSize;
|
|
1623
1662
|
if (isFromId) {
|
|
1624
1663
|
if (itemById === undefined) {
|
|
1625
|
-
if (id !== fromItemId && itemConfigMap && ((
|
|
1664
|
+
if (id !== fromItemId && itemConfigMap && ((_e = itemConfigMap[id]) === null || _e === void 0 ? void 0 : _e.sticky) === 1) {
|
|
1626
1665
|
stickyComponentSize = componentSize;
|
|
1627
1666
|
stickyCollectionItem = collectionItem;
|
|
1628
1667
|
}
|
|
@@ -1728,13 +1767,20 @@ class TrackBox extends CacheMap {
|
|
|
1728
1767
|
let componentSize = typicalItemSize, itemDisplayMethod = ItemDisplayMethods.NOT_CHANGED;
|
|
1729
1768
|
if (map.has(id)) {
|
|
1730
1769
|
const bounds = map.get(id);
|
|
1731
|
-
itemDisplayMethod = (
|
|
1770
|
+
itemDisplayMethod = (_f = bounds === null || bounds === void 0 ? void 0 : bounds.method) !== null && _f !== void 0 ? _f : ItemDisplayMethods.UPDATE;
|
|
1771
|
+
const isItemNew = (_g = bounds === null || bounds === void 0 ? void 0 : bounds[IS_NEW]) !== null && _g !== void 0 ? _g : this._isLazy;
|
|
1772
|
+
if (!isItemNew && (!this._isLazy || !((_h = itemConfigMap[collection[0].id]) === null || _h === void 0 ? void 0 : _h.sticky))) {
|
|
1773
|
+
isNew = false;
|
|
1774
|
+
}
|
|
1732
1775
|
if (itemDisplayMethod === ItemDisplayMethods.CREATE) {
|
|
1733
|
-
|
|
1776
|
+
if (isNew) {
|
|
1777
|
+
deltaFromStartCreation += componentSize;
|
|
1778
|
+
}
|
|
1779
|
+
map.set(id, Object.assign(Object.assign({}, bounds), { method: ItemDisplayMethods.NOT_CHANGED, isNew }));
|
|
1734
1780
|
}
|
|
1735
1781
|
}
|
|
1736
1782
|
if (deletedItemsMap.hasOwnProperty(i)) {
|
|
1737
|
-
const bounds = deletedItemsMap[i], size = (
|
|
1783
|
+
const bounds = deletedItemsMap[i], size = (_j = bounds === null || bounds === void 0 ? void 0 : bounds[sizeProperty]) !== null && _j !== void 0 ? _j : typicalItemSize;
|
|
1738
1784
|
if (y < scrollSize - size) {
|
|
1739
1785
|
leftSizeOfDeletedItems += size;
|
|
1740
1786
|
}
|
|
@@ -1742,7 +1788,9 @@ class TrackBox extends CacheMap {
|
|
|
1742
1788
|
if (y < scrollSize - componentSize) {
|
|
1743
1789
|
switch (itemDisplayMethod) {
|
|
1744
1790
|
case ItemDisplayMethods.CREATE: {
|
|
1745
|
-
|
|
1791
|
+
if (!isNew) {
|
|
1792
|
+
leftSizeOfUpdatedItems += componentSize;
|
|
1793
|
+
}
|
|
1746
1794
|
break;
|
|
1747
1795
|
}
|
|
1748
1796
|
case ItemDisplayMethods.UPDATE: {
|
|
@@ -1839,7 +1887,7 @@ class TrackBox extends CacheMap {
|
|
|
1839
1887
|
height: isVertical ? size : normalizedItemHeight,
|
|
1840
1888
|
delta: 0,
|
|
1841
1889
|
}, config = {
|
|
1842
|
-
new: cache
|
|
1890
|
+
new: (cache === null || cache === void 0 ? void 0 : cache[IS_NEW]) === true,
|
|
1843
1891
|
odd: isOdd,
|
|
1844
1892
|
even: !isOdd,
|
|
1845
1893
|
isVertical,
|
|
@@ -1881,7 +1929,7 @@ class TrackBox extends CacheMap {
|
|
|
1881
1929
|
height: h,
|
|
1882
1930
|
delta: 0,
|
|
1883
1931
|
}, config = {
|
|
1884
|
-
new: cache
|
|
1932
|
+
new: (cache === null || cache === void 0 ? void 0 : cache[IS_NEW]) === true,
|
|
1885
1933
|
odd: isOdd,
|
|
1886
1934
|
even: !isOdd,
|
|
1887
1935
|
isVertical,
|
|
@@ -1922,7 +1970,7 @@ class TrackBox extends CacheMap {
|
|
|
1922
1970
|
height: isVertical ? size : normalizedItemHeight,
|
|
1923
1971
|
delta: 0,
|
|
1924
1972
|
}, config = {
|
|
1925
|
-
new: cache
|
|
1973
|
+
new: (cache === null || cache === void 0 ? void 0 : cache[IS_NEW]) === true,
|
|
1926
1974
|
odd: isOdd,
|
|
1927
1975
|
even: !isOdd,
|
|
1928
1976
|
isVertical,
|
|
@@ -2134,6 +2182,20 @@ const copyValueAsReadonly = (source) => {
|
|
|
2134
2182
|
return source;
|
|
2135
2183
|
};
|
|
2136
2184
|
|
|
2185
|
+
const NORMAL_ALIASES = [CollectionModes.NORMAL, 'normal'], LAZY_ALIASES = [CollectionModes.LAZY, 'lazy'];
|
|
2186
|
+
/**
|
|
2187
|
+
* Determines the axis membership of a virtual list
|
|
2188
|
+
* @link https://github.com/DjonnyX/ng-virtual-list/blob/14.x/projects/ng-virtual-list/src/lib/utils/isCollectionMode.ts
|
|
2189
|
+
* @author Evgenii Grebennikov
|
|
2190
|
+
* @email djonnyx@gmail.com
|
|
2191
|
+
*/
|
|
2192
|
+
const isCollectionMode = (src, expected) => {
|
|
2193
|
+
if (LAZY_ALIASES.includes(expected)) {
|
|
2194
|
+
return LAZY_ALIASES.includes(src);
|
|
2195
|
+
}
|
|
2196
|
+
return NORMAL_ALIASES.includes(src);
|
|
2197
|
+
};
|
|
2198
|
+
|
|
2137
2199
|
const ROLE_LIST = 'list', ROLE_LIST_BOX = 'listbox';
|
|
2138
2200
|
const validateScrollIteration = (value) => {
|
|
2139
2201
|
return Number.isNaN(value) || (value < 0) ? 0 : value > MAX_SCROLL_TO_ITERATIONS ? MAX_SCROLL_TO_ITERATIONS : value;
|
|
@@ -2375,6 +2437,16 @@ class NgVirtualListComponent extends DisposableComponent {
|
|
|
2375
2437
|
}
|
|
2376
2438
|
return v;
|
|
2377
2439
|
};
|
|
2440
|
+
this._$collectionMode = new BehaviorSubject$1(DEFAULT_COLLECTION_MODE);
|
|
2441
|
+
this.$collectionMode = this._$collectionMode.asObservable();
|
|
2442
|
+
this._collectionModeTransform = (v) => {
|
|
2443
|
+
const valid = validateString(v) && (v === 'normal' || v === 'lazy');
|
|
2444
|
+
if (!valid) {
|
|
2445
|
+
console.error('The "direction" parameter must have the value `normal` or `lazy`.');
|
|
2446
|
+
return DEFAULT_COLLECTION_MODE;
|
|
2447
|
+
}
|
|
2448
|
+
return v;
|
|
2449
|
+
};
|
|
2378
2450
|
this._$bufferSize = new BehaviorSubject$1(DEFAULT_BUFFER_SIZE);
|
|
2379
2451
|
this.$bufferSize = this._$bufferSize.asObservable();
|
|
2380
2452
|
this._bufferSizeTransform = (v) => {
|
|
@@ -2431,6 +2503,7 @@ class NgVirtualListComponent extends DisposableComponent {
|
|
|
2431
2503
|
return v;
|
|
2432
2504
|
};
|
|
2433
2505
|
this._isVertical = this.getIsVertical();
|
|
2506
|
+
this._isLazy = this.getIsLazy();
|
|
2434
2507
|
this._$focusedElement = new BehaviorSubject$1(undefined);
|
|
2435
2508
|
this.$focusedElement = this._$focusedElement.asObservable();
|
|
2436
2509
|
this._isSnappingMethodAdvanced = this.getIsSnappingMethodAdvanced();
|
|
@@ -2530,6 +2603,21 @@ class NgVirtualListComponent extends DisposableComponent {
|
|
|
2530
2603
|
this._$cacheVersion.next(v);
|
|
2531
2604
|
};
|
|
2532
2605
|
this._$cacheVersion = new BehaviorSubject$1(-1);
|
|
2606
|
+
this._isResetedReachStart = true;
|
|
2607
|
+
this._onTrackBoxResetHandler = (v) => {
|
|
2608
|
+
var _a;
|
|
2609
|
+
if (v) {
|
|
2610
|
+
this._isResetedReachStart = true;
|
|
2611
|
+
const container = (_a = this._container) === null || _a === void 0 ? void 0 : _a.nativeElement;
|
|
2612
|
+
if (container) {
|
|
2613
|
+
const params = {
|
|
2614
|
+
[this._isVertical ? TOP_PROP_NAME : LEFT_PROP_NAME]: 0,
|
|
2615
|
+
behavior: BEHAVIOR_INSTANT,
|
|
2616
|
+
};
|
|
2617
|
+
container.scrollTo(params);
|
|
2618
|
+
}
|
|
2619
|
+
}
|
|
2620
|
+
};
|
|
2533
2621
|
this._componentsResizeObserver = new ResizeObserver(() => {
|
|
2534
2622
|
this._trackBox.changes();
|
|
2535
2623
|
});
|
|
@@ -2573,12 +2661,13 @@ class NgVirtualListComponent extends DisposableComponent {
|
|
|
2573
2661
|
})).subscribe();
|
|
2574
2662
|
this._trackBox.displayComponents = this._displayComponents;
|
|
2575
2663
|
const $trackBy = this.$trackBy, $selectByClick = this.$selectByClick, $collapseByClick = this.$collapseByClick, $isScrollStart = this._$isScrollStart.asObservable(), $isScrollFinished = this._$isScrollFinished.asObservable();
|
|
2576
|
-
$isScrollStart.pipe(takeUntil(this._$unsubscribe), distinctUntilChanged(),
|
|
2577
|
-
if (v) {
|
|
2664
|
+
$isScrollStart.pipe(takeUntil(this._$unsubscribe), distinctUntilChanged(), tap(v => {
|
|
2665
|
+
if (v && !this._isResetedReachStart) {
|
|
2578
2666
|
this.onScrollReachStart.emit();
|
|
2579
2667
|
}
|
|
2668
|
+
this._isResetedReachStart = false;
|
|
2580
2669
|
})).subscribe();
|
|
2581
|
-
$isScrollFinished.pipe(takeUntil(this._$unsubscribe), distinctUntilChanged(),
|
|
2670
|
+
$isScrollFinished.pipe(takeUntil(this._$unsubscribe), distinctUntilChanged(), tap(v => {
|
|
2582
2671
|
if (v) {
|
|
2583
2672
|
this.onScrollReachEnd.emit();
|
|
2584
2673
|
}
|
|
@@ -2592,7 +2681,10 @@ class NgVirtualListComponent extends DisposableComponent {
|
|
|
2592
2681
|
$trackBy.pipe(takeUntil(this._$unsubscribe), tap(v => {
|
|
2593
2682
|
this._trackBox.trackingPropertyName = v;
|
|
2594
2683
|
})).subscribe();
|
|
2595
|
-
const $bounds = this._$bounds.asObservable().pipe(filter(b => !!b)), $items = this.$items.pipe(map$1(i => !i ? [] : i)), $scrollSize = this._$scrollSize.asObservable(), $itemSize = this.$itemSize.pipe(map$1(v => v <= 0 ? DEFAULT_ITEM_SIZE : v)), $bufferSize = this.$bufferSize.pipe(map$1(v => v < 0 ? DEFAULT_BUFFER_SIZE : v)), $maxBufferSize = this.$maxBufferSize.pipe(map$1(v => v < 0 ? DEFAULT_MAX_BUFFER_SIZE : v)), $itemConfigMap = this.$itemConfigMap.pipe(map$1(v => !v ? {} : v)), $snap = this.$snap, $isVertical = this.$direction.pipe(map$1(v => this.getIsVertical(v || DEFAULT_DIRECTION))), $dynamicSize = this.$dynamicSize, $enabledBufferOptimization = this.$enabledBufferOptimization, $snappingMethod = this.$snappingMethod.pipe(map$1(v => this.getIsSnappingMethodAdvanced(v || DEFAULT_SNAPPING_METHOD))), $methodForSelecting = this.$methodForSelecting, $selectedIds = this.$selectedIds, $collapsedIds = this.$collapsedIds.pipe(map$1(v => Array.isArray(v) ? v : [])), $collapsedItemIds = this._$collapsedItemIds.asObservable().pipe(map$1(v => Array.isArray(v) ? v : [])), $actualItems = this._$actualItems.asObservable(), $cacheVersion = this.$cacheVersion;
|
|
2684
|
+
const $bounds = this._$bounds.asObservable().pipe(filter(b => !!b)), $items = this.$items.pipe(map$1(i => !i ? [] : i)), $scrollSize = this._$scrollSize.asObservable(), $itemSize = this.$itemSize.pipe(map$1(v => v <= 0 ? DEFAULT_ITEM_SIZE : v)), $bufferSize = this.$bufferSize.pipe(map$1(v => v < 0 ? DEFAULT_BUFFER_SIZE : v)), $maxBufferSize = this.$maxBufferSize.pipe(map$1(v => v < 0 ? DEFAULT_MAX_BUFFER_SIZE : v)), $itemConfigMap = this.$itemConfigMap.pipe(map$1(v => !v ? {} : v)), $snap = this.$snap, $isVertical = this.$direction.pipe(map$1(v => this.getIsVertical(v || DEFAULT_DIRECTION))), $isLazy = this.$collectionMode.pipe(map$1(v => this.getIsLazy(v || DEFAULT_COLLECTION_MODE))), $dynamicSize = this.$dynamicSize, $enabledBufferOptimization = this.$enabledBufferOptimization, $snappingMethod = this.$snappingMethod.pipe(map$1(v => this.getIsSnappingMethodAdvanced(v || DEFAULT_SNAPPING_METHOD))), $methodForSelecting = this.$methodForSelecting, $selectedIds = this.$selectedIds, $collapsedIds = this.$collapsedIds.pipe(map$1(v => Array.isArray(v) ? v : [])), $collapsedItemIds = this._$collapsedItemIds.asObservable().pipe(map$1(v => Array.isArray(v) ? v : [])), $actualItems = this._$actualItems.asObservable(), $cacheVersion = this.$cacheVersion;
|
|
2685
|
+
$isLazy.pipe(takeUntil(this._$unsubscribe), tap(v => {
|
|
2686
|
+
this._trackBox.isLazy = v;
|
|
2687
|
+
})).subscribe();
|
|
2596
2688
|
combineLatest([$items, $itemSize, this.$initialized]).pipe(takeUntil(this._$unsubscribe), distinctUntilChanged(), filter(([, , init]) => !!init), map$1(([items, itemSize]) => ({ items, itemSize })), tap(({ items, itemSize }) => {
|
|
2597
2689
|
this._trackBox.resetCollection(items, itemSize);
|
|
2598
2690
|
})).subscribe();
|
|
@@ -2909,6 +3001,19 @@ class NgVirtualListComponent extends DisposableComponent {
|
|
|
2909
3001
|
}
|
|
2910
3002
|
;
|
|
2911
3003
|
get direction() { return this._$direction.getValue(); }
|
|
3004
|
+
/**
|
|
3005
|
+
* Determines the action modes for collection elements. Default value is "normal".
|
|
3006
|
+
*/
|
|
3007
|
+
set collectionMode(v) {
|
|
3008
|
+
if (this._$collectionMode.getValue() === v) {
|
|
3009
|
+
return;
|
|
3010
|
+
}
|
|
3011
|
+
const transformedValue = this._collectionModeTransform(v);
|
|
3012
|
+
this._$collectionMode.next(transformedValue);
|
|
3013
|
+
this._cdr.markForCheck();
|
|
3014
|
+
}
|
|
3015
|
+
;
|
|
3016
|
+
get collectionMode() { return this._$collectionMode.getValue(); }
|
|
2912
3017
|
/**
|
|
2913
3018
|
* Number of elements outside the scope of visibility. Default value is 2.
|
|
2914
3019
|
*/
|
|
@@ -2992,13 +3097,13 @@ class NgVirtualListComponent extends DisposableComponent {
|
|
|
2992
3097
|
}
|
|
2993
3098
|
listenCacheChangesIfNeed(value) {
|
|
2994
3099
|
if (value) {
|
|
2995
|
-
if (!this._trackBox.hasEventListener(
|
|
2996
|
-
this._trackBox.addEventListener(
|
|
3100
|
+
if (!this._trackBox.hasEventListener(TrackBoxEvents.CHANGE, this._onTrackBoxChangeHandler)) {
|
|
3101
|
+
this._trackBox.addEventListener(TrackBoxEvents.CHANGE, this._onTrackBoxChangeHandler);
|
|
2997
3102
|
}
|
|
2998
3103
|
}
|
|
2999
3104
|
else {
|
|
3000
|
-
if (this._trackBox.hasEventListener(
|
|
3001
|
-
this._trackBox.removeEventListener(
|
|
3105
|
+
if (this._trackBox.hasEventListener(TrackBoxEvents.CHANGE, this._onTrackBoxChangeHandler)) {
|
|
3106
|
+
this._trackBox.removeEventListener(TrackBoxEvents.CHANGE, this._onTrackBoxChangeHandler);
|
|
3002
3107
|
}
|
|
3003
3108
|
}
|
|
3004
3109
|
}
|
|
@@ -3022,6 +3127,10 @@ class NgVirtualListComponent extends DisposableComponent {
|
|
|
3022
3127
|
const dir = d || this.direction;
|
|
3023
3128
|
return isDirection(dir, Directions.VERTICAL);
|
|
3024
3129
|
}
|
|
3130
|
+
getIsLazy(m) {
|
|
3131
|
+
const mode = m || this.collectionMode;
|
|
3132
|
+
return isCollectionMode(mode, CollectionModes.LAZY);
|
|
3133
|
+
}
|
|
3025
3134
|
createDisplayComponentsIfNeed(displayItems) {
|
|
3026
3135
|
if (!displayItems || !this._listContainerRef) {
|
|
3027
3136
|
this._trackBox.setDisplayObjectIndexMapById({});
|
|
@@ -3222,7 +3331,7 @@ class NgVirtualListComponent extends DisposableComponent {
|
|
|
3222
3331
|
}
|
|
3223
3332
|
NgVirtualListComponent.__nextId = 0;
|
|
3224
3333
|
NgVirtualListComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: NgVirtualListComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: NgVirtualListService }], target: i0.ɵɵFactoryTarget.Component });
|
|
3225
|
-
NgVirtualListComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: NgVirtualListComponent, selector: "ng-virtual-list", inputs: { items: "items", selectedIds: "selectedIds", collapsedIds: "collapsedIds", selectByClick: "selectByClick", collapseByClick: "collapseByClick", snap: "snap", enabledBufferOptimization: "enabledBufferOptimization", itemRenderer: "itemRenderer", itemConfigMap: "itemConfigMap", itemSize: "itemSize", dynamicSize: "dynamicSize", direction: "direction", bufferSize: "bufferSize", maxBufferSize: "maxBufferSize", snappingMethod: "snappingMethod", methodForSelecting: "methodForSelecting", trackBy: "trackBy" }, outputs: { onScroll: "onScroll", onScrollEnd: "onScrollEnd", onViewportChange: "onViewportChange", onItemClick: "onItemClick", onSelect: "onSelect", onCollapse: "onCollapse", onScrollReachStart: "onScrollReachStart", onScrollReachEnd: "onScrollReachEnd" }, host: { styleAttribute: "position: relative;" }, providers: [NgVirtualListService], viewQueries: [{ propertyName: "_listContainerRef", first: true, predicate: ["renderersContainer"], descendants: true, read: ViewContainerRef }, { propertyName: "_container", first: true, predicate: ["container"], descendants: true, read: (ElementRef) }, { propertyName: "_list", first: true, predicate: ["list"], descendants: true, read: (ElementRef) }, { propertyName: "_snapContainerRef", first: true, predicate: ["snapRendererContainer"], descendants: true, read: ViewContainerRef }, { propertyName: "_snappedContainer", first: true, predicate: ["snapped"], descendants: true, read: ViewContainerRef }], usesInheritance: true, ngImport: i0, template: "<div *ngIf=\"snap\" #snapped part=\"snapped-item\" class=\"ngvl__list-snapper\">\r\n <ng-container #snapRendererContainer></ng-container>\r\n</div>\r\n<div #container part=\"scroller\" class=\"ngvl__scroller\">\r\n <div [attr.aria-orientation]=\"orientation\" [attr.aria-activedescendant]=\"$focusedElement | async\" #list part=\"list\"\r\n class=\"ngvl__list\">\r\n <ng-container #renderersContainer></ng-container>\r\n </div>\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"], dependencies: [{ kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i2.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.ShadowDom });
|
|
3334
|
+
NgVirtualListComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: NgVirtualListComponent, selector: "ng-virtual-list", inputs: { items: "items", selectedIds: "selectedIds", collapsedIds: "collapsedIds", selectByClick: "selectByClick", collapseByClick: "collapseByClick", snap: "snap", enabledBufferOptimization: "enabledBufferOptimization", itemRenderer: "itemRenderer", itemConfigMap: "itemConfigMap", itemSize: "itemSize", dynamicSize: "dynamicSize", direction: "direction", collectionMode: "collectionMode", bufferSize: "bufferSize", maxBufferSize: "maxBufferSize", snappingMethod: "snappingMethod", methodForSelecting: "methodForSelecting", trackBy: "trackBy" }, outputs: { onScroll: "onScroll", onScrollEnd: "onScrollEnd", onViewportChange: "onViewportChange", onItemClick: "onItemClick", onSelect: "onSelect", onCollapse: "onCollapse", onScrollReachStart: "onScrollReachStart", onScrollReachEnd: "onScrollReachEnd" }, host: { styleAttribute: "position: relative;" }, providers: [NgVirtualListService], viewQueries: [{ propertyName: "_listContainerRef", first: true, predicate: ["renderersContainer"], descendants: true, read: ViewContainerRef }, { propertyName: "_container", first: true, predicate: ["container"], descendants: true, read: (ElementRef) }, { propertyName: "_list", first: true, predicate: ["list"], descendants: true, read: (ElementRef) }, { propertyName: "_snapContainerRef", first: true, predicate: ["snapRendererContainer"], descendants: true, read: ViewContainerRef }, { propertyName: "_snappedContainer", first: true, predicate: ["snapped"], descendants: true, read: ViewContainerRef }], usesInheritance: true, ngImport: i0, template: "<div *ngIf=\"snap\" #snapped part=\"snapped-item\" class=\"ngvl__list-snapper\">\r\n <ng-container #snapRendererContainer></ng-container>\r\n</div>\r\n<div #container part=\"scroller\" class=\"ngvl__scroller\">\r\n <div [attr.aria-orientation]=\"orientation\" [attr.aria-activedescendant]=\"$focusedElement | async\" #list part=\"list\"\r\n class=\"ngvl__list\">\r\n <ng-container #renderersContainer></ng-container>\r\n </div>\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"], dependencies: [{ kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i2.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.ShadowDom });
|
|
3226
3335
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: NgVirtualListComponent, decorators: [{
|
|
3227
3336
|
type: Component,
|
|
3228
3337
|
args: [{ selector: 'ng-virtual-list', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.ShadowDom, providers: [NgVirtualListService], host: {
|
|
@@ -3283,6 +3392,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImpor
|
|
|
3283
3392
|
type: Input
|
|
3284
3393
|
}], direction: [{
|
|
3285
3394
|
type: Input
|
|
3395
|
+
}], collectionMode: [{
|
|
3396
|
+
type: Input
|
|
3286
3397
|
}], bufferSize: [{
|
|
3287
3398
|
type: Input
|
|
3288
3399
|
}], maxBufferSize: [{
|
|
@@ -3318,5 +3429,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImpor
|
|
|
3318
3429
|
* Generated bundle index. Do not edit.
|
|
3319
3430
|
*/
|
|
3320
3431
|
|
|
3321
|
-
export { Directions, MethodsForSelecting, NgVirtualListComponent, NgVirtualListItemComponent, NgVirtualListModule, SnappingMethods };
|
|
3432
|
+
export { CollectionModes, Directions, MethodsForSelecting, NgVirtualListComponent, NgVirtualListItemComponent, NgVirtualListModule, SnappingMethods };
|
|
3322
3433
|
//# sourceMappingURL=ng-virtual-list.mjs.map
|