@legendapp/list 3.0.0-beta.48 → 3.0.0-beta.49
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/index.d.ts +1 -0
- package/index.js +56 -14
- package/index.mjs +56 -14
- package/index.native.js +56 -14
- package/index.native.mjs +56 -14
- package/package.json +1 -1
- package/react-native.js +56 -14
- package/react-native.mjs +56 -14
- package/react-native.web.js +56 -14
- package/react-native.web.mjs +56 -14
- package/react.js +56 -14
- package/react.mjs +56 -14
package/index.native.mjs
CHANGED
|
@@ -1536,7 +1536,7 @@ function getId(state, index) {
|
|
|
1536
1536
|
}
|
|
1537
1537
|
|
|
1538
1538
|
// src/core/addTotalSize.ts
|
|
1539
|
-
function addTotalSize(ctx, key, add) {
|
|
1539
|
+
function addTotalSize(ctx, key, add, notifyTotalSize = true) {
|
|
1540
1540
|
const state = ctx.state;
|
|
1541
1541
|
const prevTotalSize = state.totalSize;
|
|
1542
1542
|
let totalSize = state.totalSize;
|
|
@@ -1555,25 +1555,29 @@ function addTotalSize(ctx, key, add) {
|
|
|
1555
1555
|
} else {
|
|
1556
1556
|
state.pendingTotalSize = void 0;
|
|
1557
1557
|
state.totalSize = totalSize;
|
|
1558
|
-
|
|
1558
|
+
if (notifyTotalSize) {
|
|
1559
|
+
set$(ctx, "totalSize", totalSize);
|
|
1560
|
+
}
|
|
1559
1561
|
}
|
|
1562
|
+
} else if (notifyTotalSize && ctx.values.get("totalSize") !== totalSize) {
|
|
1563
|
+
set$(ctx, "totalSize", totalSize);
|
|
1560
1564
|
}
|
|
1561
1565
|
}
|
|
1562
1566
|
|
|
1563
1567
|
// src/core/setSize.ts
|
|
1564
|
-
function setSize(ctx, itemKey, size) {
|
|
1568
|
+
function setSize(ctx, itemKey, size, notifyTotalSize = true) {
|
|
1565
1569
|
const state = ctx.state;
|
|
1566
1570
|
const { sizes } = state;
|
|
1567
1571
|
const previousSize = sizes.get(itemKey);
|
|
1568
1572
|
const diff = previousSize !== void 0 ? size - previousSize : size;
|
|
1569
1573
|
if (diff !== 0) {
|
|
1570
|
-
addTotalSize(ctx, itemKey, diff);
|
|
1574
|
+
addTotalSize(ctx, itemKey, diff, notifyTotalSize);
|
|
1571
1575
|
}
|
|
1572
1576
|
sizes.set(itemKey, size);
|
|
1573
1577
|
}
|
|
1574
1578
|
|
|
1575
1579
|
// src/utils/getItemSize.ts
|
|
1576
|
-
function getItemSize(ctx, key, index, data, useAverageSize, preferCachedSize) {
|
|
1580
|
+
function getItemSize(ctx, key, index, data, useAverageSize, preferCachedSize, notifyTotalSize) {
|
|
1577
1581
|
var _a3, _b, _c;
|
|
1578
1582
|
const state = ctx.state;
|
|
1579
1583
|
const {
|
|
@@ -1619,7 +1623,7 @@ function getItemSize(ctx, key, index, data, useAverageSize, preferCachedSize) {
|
|
|
1619
1623
|
if (size === void 0) {
|
|
1620
1624
|
size = getEstimatedItemSize ? getEstimatedItemSize(data, index, itemType) : estimatedItemSize;
|
|
1621
1625
|
}
|
|
1622
|
-
setSize(ctx, key, size);
|
|
1626
|
+
setSize(ctx, key, size, notifyTotalSize);
|
|
1623
1627
|
return size;
|
|
1624
1628
|
}
|
|
1625
1629
|
function getItemSizeAtIndex(ctx, index) {
|
|
@@ -2142,10 +2146,10 @@ function getMountedBufferedIndices(state) {
|
|
|
2142
2146
|
function getMountedNoBufferIndices(state) {
|
|
2143
2147
|
return getMountedIndicesInRange(state, state.startNoBuffer, state.endNoBuffer);
|
|
2144
2148
|
}
|
|
2145
|
-
function checkAllSizesKnown(state, indices
|
|
2149
|
+
function checkAllSizesKnown(state, indices) {
|
|
2146
2150
|
return indices.length > 0 && indices.every((index) => {
|
|
2147
2151
|
const key = getId(state, index);
|
|
2148
|
-
return state.sizesKnown.has(key);
|
|
2152
|
+
return key !== void 0 && state.sizesKnown.has(key);
|
|
2149
2153
|
});
|
|
2150
2154
|
}
|
|
2151
2155
|
|
|
@@ -3364,6 +3368,7 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
|
|
|
3364
3368
|
const maxVisibleArea = scrollBottomBuffered + 1e3;
|
|
3365
3369
|
const useAverageSize = !getEstimatedItemSize;
|
|
3366
3370
|
const preferCachedSize = !doMVCP || dataChanged || state.scrollAdjustHandler.getAdjust() !== 0 || ((_b = peek$(ctx, "scrollAdjustPending")) != null ? _b : 0) !== 0;
|
|
3371
|
+
const notifyTotalSizeWhileCachingSizes = false;
|
|
3367
3372
|
let currentRowTop = 0;
|
|
3368
3373
|
let column = 1;
|
|
3369
3374
|
let maxSizeInRow = 0;
|
|
@@ -3391,7 +3396,15 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
|
|
|
3391
3396
|
const prevIndex = startIndex - 1;
|
|
3392
3397
|
const prevId = getId(state, prevIndex);
|
|
3393
3398
|
const prevPosition = (_c = positions[prevIndex]) != null ? _c : 0;
|
|
3394
|
-
const prevSize = (_d = sizesKnown.get(prevId)) != null ? _d : getItemSize(
|
|
3399
|
+
const prevSize = (_d = sizesKnown.get(prevId)) != null ? _d : getItemSize(
|
|
3400
|
+
ctx,
|
|
3401
|
+
prevId,
|
|
3402
|
+
prevIndex,
|
|
3403
|
+
data[prevIndex],
|
|
3404
|
+
useAverageSize,
|
|
3405
|
+
preferCachedSize,
|
|
3406
|
+
notifyTotalSizeWhileCachingSizes
|
|
3407
|
+
);
|
|
3395
3408
|
currentRowTop = prevPosition + prevSize;
|
|
3396
3409
|
}
|
|
3397
3410
|
}
|
|
@@ -3424,7 +3437,7 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
|
|
|
3424
3437
|
maxSizeInRow = 0;
|
|
3425
3438
|
}
|
|
3426
3439
|
const knownSize = sizesKnown.get(id);
|
|
3427
|
-
const size = knownSize !== void 0 ? knownSize : getItemSize(ctx, id, i, data[i], useAverageSize, preferCachedSize);
|
|
3440
|
+
const size = knownSize !== void 0 ? knownSize : getItemSize(ctx, id, i, data[i], useAverageSize, preferCachedSize, notifyTotalSizeWhileCachingSizes);
|
|
3428
3441
|
if (IS_DEV && needsIndexByKey) {
|
|
3429
3442
|
if (indexByKeyForChecking.has(id)) {
|
|
3430
3443
|
console.error(
|
|
@@ -3899,7 +3912,7 @@ function handleStickyRecycling(ctx, stickyArray, scroll, drawDistance, currentSt
|
|
|
3899
3912
|
function calculateItemsInView(ctx, params = {}) {
|
|
3900
3913
|
const state = ctx.state;
|
|
3901
3914
|
batchedUpdates(() => {
|
|
3902
|
-
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
3915
|
+
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
3903
3916
|
const {
|
|
3904
3917
|
columns,
|
|
3905
3918
|
columnSpans,
|
|
@@ -4188,6 +4201,7 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4188
4201
|
state.containerItemTypes.set(containerIndex, requiredItemTypes[idx]);
|
|
4189
4202
|
}
|
|
4190
4203
|
containerItemKeys.set(id, containerIndex);
|
|
4204
|
+
(_p = state.userScrollAnchorResetKeys) == null ? void 0 : _p.add(id);
|
|
4191
4205
|
const containerSticky = `containerSticky${containerIndex}`;
|
|
4192
4206
|
const isSticky = stickyIndicesSet.has(i);
|
|
4193
4207
|
const isAlwaysRender = alwaysRenderSet.has(i);
|
|
@@ -4215,10 +4229,13 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4215
4229
|
}
|
|
4216
4230
|
}
|
|
4217
4231
|
}
|
|
4232
|
+
if (((_q = state.userScrollAnchorResetKeys) == null ? void 0 : _q.size) === 0) {
|
|
4233
|
+
state.userScrollAnchorResetKeys = void 0;
|
|
4234
|
+
}
|
|
4218
4235
|
if (alwaysRenderArr.length > 0) {
|
|
4219
4236
|
for (const index of alwaysRenderArr) {
|
|
4220
4237
|
if (index < 0 || index >= dataLength) continue;
|
|
4221
|
-
const id = (
|
|
4238
|
+
const id = (_r = idCache[index]) != null ? _r : getId(state, index);
|
|
4222
4239
|
const containerIndex = containerItemKeys.get(id);
|
|
4223
4240
|
if (containerIndex !== void 0) {
|
|
4224
4241
|
state.stickyContainerPool.add(containerIndex);
|
|
@@ -4580,7 +4597,14 @@ function updateScroll(ctx, newScroll, forceUpdate) {
|
|
|
4580
4597
|
(_a4 = state.triggerCalculateItemsInView) == null ? void 0 : _a4.call(state, { doMVCP: scrollingTo !== void 0 });
|
|
4581
4598
|
checkThresholds(ctx);
|
|
4582
4599
|
};
|
|
4583
|
-
if (
|
|
4600
|
+
if (scrollLength > 0 && scrollingTo === void 0 && scrollDelta > scrollLength && !state.pendingNativeMVCPAdjust) {
|
|
4601
|
+
state.mvcpAnchorLock = void 0;
|
|
4602
|
+
state.pendingNativeMVCPAdjust = void 0;
|
|
4603
|
+
state.userScrollAnchorResetKeys = /* @__PURE__ */ new Set();
|
|
4604
|
+
if (state.queuedMVCPRecalculate !== void 0) {
|
|
4605
|
+
cancelAnimationFrame(state.queuedMVCPRecalculate);
|
|
4606
|
+
state.queuedMVCPRecalculate = void 0;
|
|
4607
|
+
}
|
|
4584
4608
|
flushSync(runCalculateItems);
|
|
4585
4609
|
} else {
|
|
4586
4610
|
runCalculateItems();
|
|
@@ -4763,6 +4787,20 @@ function maybeUpdateAnchoredEndSpace(ctx) {
|
|
|
4763
4787
|
// src/core/updateItemSize.ts
|
|
4764
4788
|
function runOrScheduleMVCPRecalculate(ctx) {
|
|
4765
4789
|
const state = ctx.state;
|
|
4790
|
+
if (state.userScrollAnchorResetKeys !== void 0) {
|
|
4791
|
+
if (state.queuedMVCPRecalculate !== void 0) {
|
|
4792
|
+
return;
|
|
4793
|
+
}
|
|
4794
|
+
state.queuedMVCPRecalculate = requestAnimationFrame(() => {
|
|
4795
|
+
var _a3;
|
|
4796
|
+
state.queuedMVCPRecalculate = void 0;
|
|
4797
|
+
calculateItemsInView(ctx);
|
|
4798
|
+
if (((_a3 = state.userScrollAnchorResetKeys) == null ? void 0 : _a3.size) === 0) {
|
|
4799
|
+
state.userScrollAnchorResetKeys = void 0;
|
|
4800
|
+
}
|
|
4801
|
+
});
|
|
4802
|
+
return;
|
|
4803
|
+
}
|
|
4766
4804
|
if (Platform.OS === "web") {
|
|
4767
4805
|
if (!state.mvcpAnchorLock) {
|
|
4768
4806
|
if (state.queuedMVCPRecalculate !== void 0) {
|
|
@@ -4786,6 +4824,8 @@ function runOrScheduleMVCPRecalculate(ctx) {
|
|
|
4786
4824
|
function updateItemSize(ctx, itemKey, sizeObj) {
|
|
4787
4825
|
var _a3;
|
|
4788
4826
|
const state = ctx.state;
|
|
4827
|
+
const userScrollAnchorResetKeys = state.userScrollAnchorResetKeys;
|
|
4828
|
+
const didMeasureUserScrollAnchorResetItem = !!(userScrollAnchorResetKeys == null ? void 0 : userScrollAnchorResetKeys.delete(itemKey));
|
|
4789
4829
|
const {
|
|
4790
4830
|
didContainersLayout,
|
|
4791
4831
|
sizesKnown,
|
|
@@ -4864,10 +4904,12 @@ function updateItemSize(ctx, itemKey, sizeObj) {
|
|
|
4864
4904
|
if (!cur || maxOtherAxisSize > cur) {
|
|
4865
4905
|
set$(ctx, "otherAxisSize", maxOtherAxisSize);
|
|
4866
4906
|
}
|
|
4867
|
-
if (didContainersLayout || checkAllSizesKnown(state)) {
|
|
4907
|
+
if (didContainersLayout || checkAllSizesKnown(state, getMountedBufferedIndices(state))) {
|
|
4868
4908
|
if (needsRecalculate) {
|
|
4869
4909
|
state.scrollForNextCalculateItemsInView = void 0;
|
|
4870
4910
|
runOrScheduleMVCPRecalculate(ctx);
|
|
4911
|
+
} else if (didMeasureUserScrollAnchorResetItem && (userScrollAnchorResetKeys == null ? void 0 : userScrollAnchorResetKeys.size) === 0) {
|
|
4912
|
+
state.userScrollAnchorResetKeys = void 0;
|
|
4871
4913
|
}
|
|
4872
4914
|
if (shouldMaintainScrollAtEnd) {
|
|
4873
4915
|
if (maintainScrollAtEnd == null ? void 0 : maintainScrollAtEnd.onItemLayout) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legendapp/list",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.49",
|
|
4
4
|
"description": "Legend List is a drop-in replacement for FlatList with much better performance and supporting dynamically sized items.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"private": false,
|
package/react-native.js
CHANGED
|
@@ -1557,7 +1557,7 @@ function getId(state, index) {
|
|
|
1557
1557
|
}
|
|
1558
1558
|
|
|
1559
1559
|
// src/core/addTotalSize.ts
|
|
1560
|
-
function addTotalSize(ctx, key, add) {
|
|
1560
|
+
function addTotalSize(ctx, key, add, notifyTotalSize = true) {
|
|
1561
1561
|
const state = ctx.state;
|
|
1562
1562
|
const prevTotalSize = state.totalSize;
|
|
1563
1563
|
let totalSize = state.totalSize;
|
|
@@ -1576,25 +1576,29 @@ function addTotalSize(ctx, key, add) {
|
|
|
1576
1576
|
} else {
|
|
1577
1577
|
state.pendingTotalSize = void 0;
|
|
1578
1578
|
state.totalSize = totalSize;
|
|
1579
|
-
|
|
1579
|
+
if (notifyTotalSize) {
|
|
1580
|
+
set$(ctx, "totalSize", totalSize);
|
|
1581
|
+
}
|
|
1580
1582
|
}
|
|
1583
|
+
} else if (notifyTotalSize && ctx.values.get("totalSize") !== totalSize) {
|
|
1584
|
+
set$(ctx, "totalSize", totalSize);
|
|
1581
1585
|
}
|
|
1582
1586
|
}
|
|
1583
1587
|
|
|
1584
1588
|
// src/core/setSize.ts
|
|
1585
|
-
function setSize(ctx, itemKey, size) {
|
|
1589
|
+
function setSize(ctx, itemKey, size, notifyTotalSize = true) {
|
|
1586
1590
|
const state = ctx.state;
|
|
1587
1591
|
const { sizes } = state;
|
|
1588
1592
|
const previousSize = sizes.get(itemKey);
|
|
1589
1593
|
const diff = previousSize !== void 0 ? size - previousSize : size;
|
|
1590
1594
|
if (diff !== 0) {
|
|
1591
|
-
addTotalSize(ctx, itemKey, diff);
|
|
1595
|
+
addTotalSize(ctx, itemKey, diff, notifyTotalSize);
|
|
1592
1596
|
}
|
|
1593
1597
|
sizes.set(itemKey, size);
|
|
1594
1598
|
}
|
|
1595
1599
|
|
|
1596
1600
|
// src/utils/getItemSize.ts
|
|
1597
|
-
function getItemSize(ctx, key, index, data, useAverageSize, preferCachedSize) {
|
|
1601
|
+
function getItemSize(ctx, key, index, data, useAverageSize, preferCachedSize, notifyTotalSize) {
|
|
1598
1602
|
var _a3, _b, _c;
|
|
1599
1603
|
const state = ctx.state;
|
|
1600
1604
|
const {
|
|
@@ -1640,7 +1644,7 @@ function getItemSize(ctx, key, index, data, useAverageSize, preferCachedSize) {
|
|
|
1640
1644
|
if (size === void 0) {
|
|
1641
1645
|
size = getEstimatedItemSize ? getEstimatedItemSize(data, index, itemType) : estimatedItemSize;
|
|
1642
1646
|
}
|
|
1643
|
-
setSize(ctx, key, size);
|
|
1647
|
+
setSize(ctx, key, size, notifyTotalSize);
|
|
1644
1648
|
return size;
|
|
1645
1649
|
}
|
|
1646
1650
|
function getItemSizeAtIndex(ctx, index) {
|
|
@@ -2163,10 +2167,10 @@ function getMountedBufferedIndices(state) {
|
|
|
2163
2167
|
function getMountedNoBufferIndices(state) {
|
|
2164
2168
|
return getMountedIndicesInRange(state, state.startNoBuffer, state.endNoBuffer);
|
|
2165
2169
|
}
|
|
2166
|
-
function checkAllSizesKnown(state, indices
|
|
2170
|
+
function checkAllSizesKnown(state, indices) {
|
|
2167
2171
|
return indices.length > 0 && indices.every((index) => {
|
|
2168
2172
|
const key = getId(state, index);
|
|
2169
|
-
return state.sizesKnown.has(key);
|
|
2173
|
+
return key !== void 0 && state.sizesKnown.has(key);
|
|
2170
2174
|
});
|
|
2171
2175
|
}
|
|
2172
2176
|
|
|
@@ -3385,6 +3389,7 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
|
|
|
3385
3389
|
const maxVisibleArea = scrollBottomBuffered + 1e3;
|
|
3386
3390
|
const useAverageSize = !getEstimatedItemSize;
|
|
3387
3391
|
const preferCachedSize = !doMVCP || dataChanged || state.scrollAdjustHandler.getAdjust() !== 0 || ((_b = peek$(ctx, "scrollAdjustPending")) != null ? _b : 0) !== 0;
|
|
3392
|
+
const notifyTotalSizeWhileCachingSizes = false;
|
|
3388
3393
|
let currentRowTop = 0;
|
|
3389
3394
|
let column = 1;
|
|
3390
3395
|
let maxSizeInRow = 0;
|
|
@@ -3412,7 +3417,15 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
|
|
|
3412
3417
|
const prevIndex = startIndex - 1;
|
|
3413
3418
|
const prevId = getId(state, prevIndex);
|
|
3414
3419
|
const prevPosition = (_c = positions[prevIndex]) != null ? _c : 0;
|
|
3415
|
-
const prevSize = (_d = sizesKnown.get(prevId)) != null ? _d : getItemSize(
|
|
3420
|
+
const prevSize = (_d = sizesKnown.get(prevId)) != null ? _d : getItemSize(
|
|
3421
|
+
ctx,
|
|
3422
|
+
prevId,
|
|
3423
|
+
prevIndex,
|
|
3424
|
+
data[prevIndex],
|
|
3425
|
+
useAverageSize,
|
|
3426
|
+
preferCachedSize,
|
|
3427
|
+
notifyTotalSizeWhileCachingSizes
|
|
3428
|
+
);
|
|
3416
3429
|
currentRowTop = prevPosition + prevSize;
|
|
3417
3430
|
}
|
|
3418
3431
|
}
|
|
@@ -3445,7 +3458,7 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
|
|
|
3445
3458
|
maxSizeInRow = 0;
|
|
3446
3459
|
}
|
|
3447
3460
|
const knownSize = sizesKnown.get(id);
|
|
3448
|
-
const size = knownSize !== void 0 ? knownSize : getItemSize(ctx, id, i, data[i], useAverageSize, preferCachedSize);
|
|
3461
|
+
const size = knownSize !== void 0 ? knownSize : getItemSize(ctx, id, i, data[i], useAverageSize, preferCachedSize, notifyTotalSizeWhileCachingSizes);
|
|
3449
3462
|
if (IS_DEV && needsIndexByKey) {
|
|
3450
3463
|
if (indexByKeyForChecking.has(id)) {
|
|
3451
3464
|
console.error(
|
|
@@ -3920,7 +3933,7 @@ function handleStickyRecycling(ctx, stickyArray, scroll, drawDistance, currentSt
|
|
|
3920
3933
|
function calculateItemsInView(ctx, params = {}) {
|
|
3921
3934
|
const state = ctx.state;
|
|
3922
3935
|
batchedUpdates(() => {
|
|
3923
|
-
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
3936
|
+
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
3924
3937
|
const {
|
|
3925
3938
|
columns,
|
|
3926
3939
|
columnSpans,
|
|
@@ -4209,6 +4222,7 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4209
4222
|
state.containerItemTypes.set(containerIndex, requiredItemTypes[idx]);
|
|
4210
4223
|
}
|
|
4211
4224
|
containerItemKeys.set(id, containerIndex);
|
|
4225
|
+
(_p = state.userScrollAnchorResetKeys) == null ? void 0 : _p.add(id);
|
|
4212
4226
|
const containerSticky = `containerSticky${containerIndex}`;
|
|
4213
4227
|
const isSticky = stickyIndicesSet.has(i);
|
|
4214
4228
|
const isAlwaysRender = alwaysRenderSet.has(i);
|
|
@@ -4236,10 +4250,13 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4236
4250
|
}
|
|
4237
4251
|
}
|
|
4238
4252
|
}
|
|
4253
|
+
if (((_q = state.userScrollAnchorResetKeys) == null ? void 0 : _q.size) === 0) {
|
|
4254
|
+
state.userScrollAnchorResetKeys = void 0;
|
|
4255
|
+
}
|
|
4239
4256
|
if (alwaysRenderArr.length > 0) {
|
|
4240
4257
|
for (const index of alwaysRenderArr) {
|
|
4241
4258
|
if (index < 0 || index >= dataLength) continue;
|
|
4242
|
-
const id = (
|
|
4259
|
+
const id = (_r = idCache[index]) != null ? _r : getId(state, index);
|
|
4243
4260
|
const containerIndex = containerItemKeys.get(id);
|
|
4244
4261
|
if (containerIndex !== void 0) {
|
|
4245
4262
|
state.stickyContainerPool.add(containerIndex);
|
|
@@ -4601,7 +4618,14 @@ function updateScroll(ctx, newScroll, forceUpdate) {
|
|
|
4601
4618
|
(_a4 = state.triggerCalculateItemsInView) == null ? void 0 : _a4.call(state, { doMVCP: scrollingTo !== void 0 });
|
|
4602
4619
|
checkThresholds(ctx);
|
|
4603
4620
|
};
|
|
4604
|
-
if (
|
|
4621
|
+
if (scrollLength > 0 && scrollingTo === void 0 && scrollDelta > scrollLength && !state.pendingNativeMVCPAdjust) {
|
|
4622
|
+
state.mvcpAnchorLock = void 0;
|
|
4623
|
+
state.pendingNativeMVCPAdjust = void 0;
|
|
4624
|
+
state.userScrollAnchorResetKeys = /* @__PURE__ */ new Set();
|
|
4625
|
+
if (state.queuedMVCPRecalculate !== void 0) {
|
|
4626
|
+
cancelAnimationFrame(state.queuedMVCPRecalculate);
|
|
4627
|
+
state.queuedMVCPRecalculate = void 0;
|
|
4628
|
+
}
|
|
4605
4629
|
flushSync(runCalculateItems);
|
|
4606
4630
|
} else {
|
|
4607
4631
|
runCalculateItems();
|
|
@@ -4784,6 +4808,20 @@ function maybeUpdateAnchoredEndSpace(ctx) {
|
|
|
4784
4808
|
// src/core/updateItemSize.ts
|
|
4785
4809
|
function runOrScheduleMVCPRecalculate(ctx) {
|
|
4786
4810
|
const state = ctx.state;
|
|
4811
|
+
if (state.userScrollAnchorResetKeys !== void 0) {
|
|
4812
|
+
if (state.queuedMVCPRecalculate !== void 0) {
|
|
4813
|
+
return;
|
|
4814
|
+
}
|
|
4815
|
+
state.queuedMVCPRecalculate = requestAnimationFrame(() => {
|
|
4816
|
+
var _a3;
|
|
4817
|
+
state.queuedMVCPRecalculate = void 0;
|
|
4818
|
+
calculateItemsInView(ctx);
|
|
4819
|
+
if (((_a3 = state.userScrollAnchorResetKeys) == null ? void 0 : _a3.size) === 0) {
|
|
4820
|
+
state.userScrollAnchorResetKeys = void 0;
|
|
4821
|
+
}
|
|
4822
|
+
});
|
|
4823
|
+
return;
|
|
4824
|
+
}
|
|
4787
4825
|
if (Platform.OS === "web") {
|
|
4788
4826
|
if (!state.mvcpAnchorLock) {
|
|
4789
4827
|
if (state.queuedMVCPRecalculate !== void 0) {
|
|
@@ -4807,6 +4845,8 @@ function runOrScheduleMVCPRecalculate(ctx) {
|
|
|
4807
4845
|
function updateItemSize(ctx, itemKey, sizeObj) {
|
|
4808
4846
|
var _a3;
|
|
4809
4847
|
const state = ctx.state;
|
|
4848
|
+
const userScrollAnchorResetKeys = state.userScrollAnchorResetKeys;
|
|
4849
|
+
const didMeasureUserScrollAnchorResetItem = !!(userScrollAnchorResetKeys == null ? void 0 : userScrollAnchorResetKeys.delete(itemKey));
|
|
4810
4850
|
const {
|
|
4811
4851
|
didContainersLayout,
|
|
4812
4852
|
sizesKnown,
|
|
@@ -4885,10 +4925,12 @@ function updateItemSize(ctx, itemKey, sizeObj) {
|
|
|
4885
4925
|
if (!cur || maxOtherAxisSize > cur) {
|
|
4886
4926
|
set$(ctx, "otherAxisSize", maxOtherAxisSize);
|
|
4887
4927
|
}
|
|
4888
|
-
if (didContainersLayout || checkAllSizesKnown(state)) {
|
|
4928
|
+
if (didContainersLayout || checkAllSizesKnown(state, getMountedBufferedIndices(state))) {
|
|
4889
4929
|
if (needsRecalculate) {
|
|
4890
4930
|
state.scrollForNextCalculateItemsInView = void 0;
|
|
4891
4931
|
runOrScheduleMVCPRecalculate(ctx);
|
|
4932
|
+
} else if (didMeasureUserScrollAnchorResetItem && (userScrollAnchorResetKeys == null ? void 0 : userScrollAnchorResetKeys.size) === 0) {
|
|
4933
|
+
state.userScrollAnchorResetKeys = void 0;
|
|
4892
4934
|
}
|
|
4893
4935
|
if (shouldMaintainScrollAtEnd) {
|
|
4894
4936
|
if (maintainScrollAtEnd == null ? void 0 : maintainScrollAtEnd.onItemLayout) {
|
package/react-native.mjs
CHANGED
|
@@ -1536,7 +1536,7 @@ function getId(state, index) {
|
|
|
1536
1536
|
}
|
|
1537
1537
|
|
|
1538
1538
|
// src/core/addTotalSize.ts
|
|
1539
|
-
function addTotalSize(ctx, key, add) {
|
|
1539
|
+
function addTotalSize(ctx, key, add, notifyTotalSize = true) {
|
|
1540
1540
|
const state = ctx.state;
|
|
1541
1541
|
const prevTotalSize = state.totalSize;
|
|
1542
1542
|
let totalSize = state.totalSize;
|
|
@@ -1555,25 +1555,29 @@ function addTotalSize(ctx, key, add) {
|
|
|
1555
1555
|
} else {
|
|
1556
1556
|
state.pendingTotalSize = void 0;
|
|
1557
1557
|
state.totalSize = totalSize;
|
|
1558
|
-
|
|
1558
|
+
if (notifyTotalSize) {
|
|
1559
|
+
set$(ctx, "totalSize", totalSize);
|
|
1560
|
+
}
|
|
1559
1561
|
}
|
|
1562
|
+
} else if (notifyTotalSize && ctx.values.get("totalSize") !== totalSize) {
|
|
1563
|
+
set$(ctx, "totalSize", totalSize);
|
|
1560
1564
|
}
|
|
1561
1565
|
}
|
|
1562
1566
|
|
|
1563
1567
|
// src/core/setSize.ts
|
|
1564
|
-
function setSize(ctx, itemKey, size) {
|
|
1568
|
+
function setSize(ctx, itemKey, size, notifyTotalSize = true) {
|
|
1565
1569
|
const state = ctx.state;
|
|
1566
1570
|
const { sizes } = state;
|
|
1567
1571
|
const previousSize = sizes.get(itemKey);
|
|
1568
1572
|
const diff = previousSize !== void 0 ? size - previousSize : size;
|
|
1569
1573
|
if (diff !== 0) {
|
|
1570
|
-
addTotalSize(ctx, itemKey, diff);
|
|
1574
|
+
addTotalSize(ctx, itemKey, diff, notifyTotalSize);
|
|
1571
1575
|
}
|
|
1572
1576
|
sizes.set(itemKey, size);
|
|
1573
1577
|
}
|
|
1574
1578
|
|
|
1575
1579
|
// src/utils/getItemSize.ts
|
|
1576
|
-
function getItemSize(ctx, key, index, data, useAverageSize, preferCachedSize) {
|
|
1580
|
+
function getItemSize(ctx, key, index, data, useAverageSize, preferCachedSize, notifyTotalSize) {
|
|
1577
1581
|
var _a3, _b, _c;
|
|
1578
1582
|
const state = ctx.state;
|
|
1579
1583
|
const {
|
|
@@ -1619,7 +1623,7 @@ function getItemSize(ctx, key, index, data, useAverageSize, preferCachedSize) {
|
|
|
1619
1623
|
if (size === void 0) {
|
|
1620
1624
|
size = getEstimatedItemSize ? getEstimatedItemSize(data, index, itemType) : estimatedItemSize;
|
|
1621
1625
|
}
|
|
1622
|
-
setSize(ctx, key, size);
|
|
1626
|
+
setSize(ctx, key, size, notifyTotalSize);
|
|
1623
1627
|
return size;
|
|
1624
1628
|
}
|
|
1625
1629
|
function getItemSizeAtIndex(ctx, index) {
|
|
@@ -2142,10 +2146,10 @@ function getMountedBufferedIndices(state) {
|
|
|
2142
2146
|
function getMountedNoBufferIndices(state) {
|
|
2143
2147
|
return getMountedIndicesInRange(state, state.startNoBuffer, state.endNoBuffer);
|
|
2144
2148
|
}
|
|
2145
|
-
function checkAllSizesKnown(state, indices
|
|
2149
|
+
function checkAllSizesKnown(state, indices) {
|
|
2146
2150
|
return indices.length > 0 && indices.every((index) => {
|
|
2147
2151
|
const key = getId(state, index);
|
|
2148
|
-
return state.sizesKnown.has(key);
|
|
2152
|
+
return key !== void 0 && state.sizesKnown.has(key);
|
|
2149
2153
|
});
|
|
2150
2154
|
}
|
|
2151
2155
|
|
|
@@ -3364,6 +3368,7 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
|
|
|
3364
3368
|
const maxVisibleArea = scrollBottomBuffered + 1e3;
|
|
3365
3369
|
const useAverageSize = !getEstimatedItemSize;
|
|
3366
3370
|
const preferCachedSize = !doMVCP || dataChanged || state.scrollAdjustHandler.getAdjust() !== 0 || ((_b = peek$(ctx, "scrollAdjustPending")) != null ? _b : 0) !== 0;
|
|
3371
|
+
const notifyTotalSizeWhileCachingSizes = false;
|
|
3367
3372
|
let currentRowTop = 0;
|
|
3368
3373
|
let column = 1;
|
|
3369
3374
|
let maxSizeInRow = 0;
|
|
@@ -3391,7 +3396,15 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
|
|
|
3391
3396
|
const prevIndex = startIndex - 1;
|
|
3392
3397
|
const prevId = getId(state, prevIndex);
|
|
3393
3398
|
const prevPosition = (_c = positions[prevIndex]) != null ? _c : 0;
|
|
3394
|
-
const prevSize = (_d = sizesKnown.get(prevId)) != null ? _d : getItemSize(
|
|
3399
|
+
const prevSize = (_d = sizesKnown.get(prevId)) != null ? _d : getItemSize(
|
|
3400
|
+
ctx,
|
|
3401
|
+
prevId,
|
|
3402
|
+
prevIndex,
|
|
3403
|
+
data[prevIndex],
|
|
3404
|
+
useAverageSize,
|
|
3405
|
+
preferCachedSize,
|
|
3406
|
+
notifyTotalSizeWhileCachingSizes
|
|
3407
|
+
);
|
|
3395
3408
|
currentRowTop = prevPosition + prevSize;
|
|
3396
3409
|
}
|
|
3397
3410
|
}
|
|
@@ -3424,7 +3437,7 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
|
|
|
3424
3437
|
maxSizeInRow = 0;
|
|
3425
3438
|
}
|
|
3426
3439
|
const knownSize = sizesKnown.get(id);
|
|
3427
|
-
const size = knownSize !== void 0 ? knownSize : getItemSize(ctx, id, i, data[i], useAverageSize, preferCachedSize);
|
|
3440
|
+
const size = knownSize !== void 0 ? knownSize : getItemSize(ctx, id, i, data[i], useAverageSize, preferCachedSize, notifyTotalSizeWhileCachingSizes);
|
|
3428
3441
|
if (IS_DEV && needsIndexByKey) {
|
|
3429
3442
|
if (indexByKeyForChecking.has(id)) {
|
|
3430
3443
|
console.error(
|
|
@@ -3899,7 +3912,7 @@ function handleStickyRecycling(ctx, stickyArray, scroll, drawDistance, currentSt
|
|
|
3899
3912
|
function calculateItemsInView(ctx, params = {}) {
|
|
3900
3913
|
const state = ctx.state;
|
|
3901
3914
|
batchedUpdates(() => {
|
|
3902
|
-
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
3915
|
+
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
3903
3916
|
const {
|
|
3904
3917
|
columns,
|
|
3905
3918
|
columnSpans,
|
|
@@ -4188,6 +4201,7 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4188
4201
|
state.containerItemTypes.set(containerIndex, requiredItemTypes[idx]);
|
|
4189
4202
|
}
|
|
4190
4203
|
containerItemKeys.set(id, containerIndex);
|
|
4204
|
+
(_p = state.userScrollAnchorResetKeys) == null ? void 0 : _p.add(id);
|
|
4191
4205
|
const containerSticky = `containerSticky${containerIndex}`;
|
|
4192
4206
|
const isSticky = stickyIndicesSet.has(i);
|
|
4193
4207
|
const isAlwaysRender = alwaysRenderSet.has(i);
|
|
@@ -4215,10 +4229,13 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4215
4229
|
}
|
|
4216
4230
|
}
|
|
4217
4231
|
}
|
|
4232
|
+
if (((_q = state.userScrollAnchorResetKeys) == null ? void 0 : _q.size) === 0) {
|
|
4233
|
+
state.userScrollAnchorResetKeys = void 0;
|
|
4234
|
+
}
|
|
4218
4235
|
if (alwaysRenderArr.length > 0) {
|
|
4219
4236
|
for (const index of alwaysRenderArr) {
|
|
4220
4237
|
if (index < 0 || index >= dataLength) continue;
|
|
4221
|
-
const id = (
|
|
4238
|
+
const id = (_r = idCache[index]) != null ? _r : getId(state, index);
|
|
4222
4239
|
const containerIndex = containerItemKeys.get(id);
|
|
4223
4240
|
if (containerIndex !== void 0) {
|
|
4224
4241
|
state.stickyContainerPool.add(containerIndex);
|
|
@@ -4580,7 +4597,14 @@ function updateScroll(ctx, newScroll, forceUpdate) {
|
|
|
4580
4597
|
(_a4 = state.triggerCalculateItemsInView) == null ? void 0 : _a4.call(state, { doMVCP: scrollingTo !== void 0 });
|
|
4581
4598
|
checkThresholds(ctx);
|
|
4582
4599
|
};
|
|
4583
|
-
if (
|
|
4600
|
+
if (scrollLength > 0 && scrollingTo === void 0 && scrollDelta > scrollLength && !state.pendingNativeMVCPAdjust) {
|
|
4601
|
+
state.mvcpAnchorLock = void 0;
|
|
4602
|
+
state.pendingNativeMVCPAdjust = void 0;
|
|
4603
|
+
state.userScrollAnchorResetKeys = /* @__PURE__ */ new Set();
|
|
4604
|
+
if (state.queuedMVCPRecalculate !== void 0) {
|
|
4605
|
+
cancelAnimationFrame(state.queuedMVCPRecalculate);
|
|
4606
|
+
state.queuedMVCPRecalculate = void 0;
|
|
4607
|
+
}
|
|
4584
4608
|
flushSync(runCalculateItems);
|
|
4585
4609
|
} else {
|
|
4586
4610
|
runCalculateItems();
|
|
@@ -4763,6 +4787,20 @@ function maybeUpdateAnchoredEndSpace(ctx) {
|
|
|
4763
4787
|
// src/core/updateItemSize.ts
|
|
4764
4788
|
function runOrScheduleMVCPRecalculate(ctx) {
|
|
4765
4789
|
const state = ctx.state;
|
|
4790
|
+
if (state.userScrollAnchorResetKeys !== void 0) {
|
|
4791
|
+
if (state.queuedMVCPRecalculate !== void 0) {
|
|
4792
|
+
return;
|
|
4793
|
+
}
|
|
4794
|
+
state.queuedMVCPRecalculate = requestAnimationFrame(() => {
|
|
4795
|
+
var _a3;
|
|
4796
|
+
state.queuedMVCPRecalculate = void 0;
|
|
4797
|
+
calculateItemsInView(ctx);
|
|
4798
|
+
if (((_a3 = state.userScrollAnchorResetKeys) == null ? void 0 : _a3.size) === 0) {
|
|
4799
|
+
state.userScrollAnchorResetKeys = void 0;
|
|
4800
|
+
}
|
|
4801
|
+
});
|
|
4802
|
+
return;
|
|
4803
|
+
}
|
|
4766
4804
|
if (Platform.OS === "web") {
|
|
4767
4805
|
if (!state.mvcpAnchorLock) {
|
|
4768
4806
|
if (state.queuedMVCPRecalculate !== void 0) {
|
|
@@ -4786,6 +4824,8 @@ function runOrScheduleMVCPRecalculate(ctx) {
|
|
|
4786
4824
|
function updateItemSize(ctx, itemKey, sizeObj) {
|
|
4787
4825
|
var _a3;
|
|
4788
4826
|
const state = ctx.state;
|
|
4827
|
+
const userScrollAnchorResetKeys = state.userScrollAnchorResetKeys;
|
|
4828
|
+
const didMeasureUserScrollAnchorResetItem = !!(userScrollAnchorResetKeys == null ? void 0 : userScrollAnchorResetKeys.delete(itemKey));
|
|
4789
4829
|
const {
|
|
4790
4830
|
didContainersLayout,
|
|
4791
4831
|
sizesKnown,
|
|
@@ -4864,10 +4904,12 @@ function updateItemSize(ctx, itemKey, sizeObj) {
|
|
|
4864
4904
|
if (!cur || maxOtherAxisSize > cur) {
|
|
4865
4905
|
set$(ctx, "otherAxisSize", maxOtherAxisSize);
|
|
4866
4906
|
}
|
|
4867
|
-
if (didContainersLayout || checkAllSizesKnown(state)) {
|
|
4907
|
+
if (didContainersLayout || checkAllSizesKnown(state, getMountedBufferedIndices(state))) {
|
|
4868
4908
|
if (needsRecalculate) {
|
|
4869
4909
|
state.scrollForNextCalculateItemsInView = void 0;
|
|
4870
4910
|
runOrScheduleMVCPRecalculate(ctx);
|
|
4911
|
+
} else if (didMeasureUserScrollAnchorResetItem && (userScrollAnchorResetKeys == null ? void 0 : userScrollAnchorResetKeys.size) === 0) {
|
|
4912
|
+
state.userScrollAnchorResetKeys = void 0;
|
|
4871
4913
|
}
|
|
4872
4914
|
if (shouldMaintainScrollAtEnd) {
|
|
4873
4915
|
if (maintainScrollAtEnd == null ? void 0 : maintainScrollAtEnd.onItemLayout) {
|