@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.d.ts
CHANGED
|
@@ -236,6 +236,7 @@ interface InternalState$1 {
|
|
|
236
236
|
dataChanged?: boolean;
|
|
237
237
|
forceFullItemPositions?: boolean;
|
|
238
238
|
}) => void;
|
|
239
|
+
userScrollAnchorResetKeys?: Set<string>;
|
|
239
240
|
viewabilityConfigCallbackPairs: ViewabilityConfigCallbackPairs$1<any> | undefined;
|
|
240
241
|
props: {
|
|
241
242
|
alignItemsAtEnd: boolean;
|
package/index.js
CHANGED
|
@@ -2080,7 +2080,7 @@ function getId(state, index) {
|
|
|
2080
2080
|
}
|
|
2081
2081
|
|
|
2082
2082
|
// src/core/addTotalSize.ts
|
|
2083
|
-
function addTotalSize(ctx, key, add) {
|
|
2083
|
+
function addTotalSize(ctx, key, add, notifyTotalSize = true) {
|
|
2084
2084
|
const state = ctx.state;
|
|
2085
2085
|
const prevTotalSize = state.totalSize;
|
|
2086
2086
|
let totalSize = state.totalSize;
|
|
@@ -2097,25 +2097,29 @@ function addTotalSize(ctx, key, add) {
|
|
|
2097
2097
|
{
|
|
2098
2098
|
state.pendingTotalSize = void 0;
|
|
2099
2099
|
state.totalSize = totalSize;
|
|
2100
|
-
|
|
2100
|
+
if (notifyTotalSize) {
|
|
2101
|
+
set$(ctx, "totalSize", totalSize);
|
|
2102
|
+
}
|
|
2101
2103
|
}
|
|
2104
|
+
} else if (notifyTotalSize && ctx.values.get("totalSize") !== totalSize) {
|
|
2105
|
+
set$(ctx, "totalSize", totalSize);
|
|
2102
2106
|
}
|
|
2103
2107
|
}
|
|
2104
2108
|
|
|
2105
2109
|
// src/core/setSize.ts
|
|
2106
|
-
function setSize(ctx, itemKey, size) {
|
|
2110
|
+
function setSize(ctx, itemKey, size, notifyTotalSize = true) {
|
|
2107
2111
|
const state = ctx.state;
|
|
2108
2112
|
const { sizes } = state;
|
|
2109
2113
|
const previousSize = sizes.get(itemKey);
|
|
2110
2114
|
const diff = previousSize !== void 0 ? size - previousSize : size;
|
|
2111
2115
|
if (diff !== 0) {
|
|
2112
|
-
addTotalSize(ctx, itemKey, diff);
|
|
2116
|
+
addTotalSize(ctx, itemKey, diff, notifyTotalSize);
|
|
2113
2117
|
}
|
|
2114
2118
|
sizes.set(itemKey, size);
|
|
2115
2119
|
}
|
|
2116
2120
|
|
|
2117
2121
|
// src/utils/getItemSize.ts
|
|
2118
|
-
function getItemSize(ctx, key, index, data, useAverageSize, preferCachedSize) {
|
|
2122
|
+
function getItemSize(ctx, key, index, data, useAverageSize, preferCachedSize, notifyTotalSize) {
|
|
2119
2123
|
var _a3, _b, _c;
|
|
2120
2124
|
const state = ctx.state;
|
|
2121
2125
|
const {
|
|
@@ -2161,7 +2165,7 @@ function getItemSize(ctx, key, index, data, useAverageSize, preferCachedSize) {
|
|
|
2161
2165
|
if (size === void 0) {
|
|
2162
2166
|
size = getEstimatedItemSize ? getEstimatedItemSize(data, index, itemType) : estimatedItemSize;
|
|
2163
2167
|
}
|
|
2164
|
-
setSize(ctx, key, size);
|
|
2168
|
+
setSize(ctx, key, size, notifyTotalSize);
|
|
2165
2169
|
return size;
|
|
2166
2170
|
}
|
|
2167
2171
|
function getItemSizeAtIndex(ctx, index) {
|
|
@@ -2600,10 +2604,10 @@ function getMountedBufferedIndices(state) {
|
|
|
2600
2604
|
function getMountedNoBufferIndices(state) {
|
|
2601
2605
|
return getMountedIndicesInRange(state, state.startNoBuffer, state.endNoBuffer);
|
|
2602
2606
|
}
|
|
2603
|
-
function checkAllSizesKnown(state, indices
|
|
2607
|
+
function checkAllSizesKnown(state, indices) {
|
|
2604
2608
|
return indices.length > 0 && indices.every((index) => {
|
|
2605
2609
|
const key = getId(state, index);
|
|
2606
|
-
return state.sizesKnown.has(key);
|
|
2610
|
+
return key !== void 0 && state.sizesKnown.has(key);
|
|
2607
2611
|
});
|
|
2608
2612
|
}
|
|
2609
2613
|
|
|
@@ -3913,6 +3917,7 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
|
|
|
3913
3917
|
const maxVisibleArea = scrollBottomBuffered + 1e3;
|
|
3914
3918
|
const useAverageSize = !getEstimatedItemSize;
|
|
3915
3919
|
const preferCachedSize = !doMVCP || dataChanged || state.scrollAdjustHandler.getAdjust() !== 0 || ((_b = peek$(ctx, "scrollAdjustPending")) != null ? _b : 0) !== 0;
|
|
3920
|
+
const notifyTotalSizeWhileCachingSizes = false;
|
|
3916
3921
|
let currentRowTop = 0;
|
|
3917
3922
|
let column = 1;
|
|
3918
3923
|
let maxSizeInRow = 0;
|
|
@@ -3940,7 +3945,15 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
|
|
|
3940
3945
|
const prevIndex = startIndex - 1;
|
|
3941
3946
|
const prevId = getId(state, prevIndex);
|
|
3942
3947
|
const prevPosition = (_c = positions[prevIndex]) != null ? _c : 0;
|
|
3943
|
-
const prevSize = (_d = sizesKnown.get(prevId)) != null ? _d : getItemSize(
|
|
3948
|
+
const prevSize = (_d = sizesKnown.get(prevId)) != null ? _d : getItemSize(
|
|
3949
|
+
ctx,
|
|
3950
|
+
prevId,
|
|
3951
|
+
prevIndex,
|
|
3952
|
+
data[prevIndex],
|
|
3953
|
+
useAverageSize,
|
|
3954
|
+
preferCachedSize,
|
|
3955
|
+
notifyTotalSizeWhileCachingSizes
|
|
3956
|
+
);
|
|
3944
3957
|
currentRowTop = prevPosition + prevSize;
|
|
3945
3958
|
}
|
|
3946
3959
|
}
|
|
@@ -3973,7 +3986,7 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
|
|
|
3973
3986
|
maxSizeInRow = 0;
|
|
3974
3987
|
}
|
|
3975
3988
|
const knownSize = sizesKnown.get(id);
|
|
3976
|
-
const size = knownSize !== void 0 ? knownSize : getItemSize(ctx, id, i, data[i], useAverageSize, preferCachedSize);
|
|
3989
|
+
const size = knownSize !== void 0 ? knownSize : getItemSize(ctx, id, i, data[i], useAverageSize, preferCachedSize, notifyTotalSizeWhileCachingSizes);
|
|
3977
3990
|
if (IS_DEV && needsIndexByKey) {
|
|
3978
3991
|
if (indexByKeyForChecking.has(id)) {
|
|
3979
3992
|
console.error(
|
|
@@ -4448,7 +4461,7 @@ function handleStickyRecycling(ctx, stickyArray, scroll, drawDistance, currentSt
|
|
|
4448
4461
|
function calculateItemsInView(ctx, params = {}) {
|
|
4449
4462
|
const state = ctx.state;
|
|
4450
4463
|
batchedUpdates(() => {
|
|
4451
|
-
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
4464
|
+
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
4452
4465
|
const {
|
|
4453
4466
|
columns,
|
|
4454
4467
|
columnSpans,
|
|
@@ -4737,6 +4750,7 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4737
4750
|
state.containerItemTypes.set(containerIndex, requiredItemTypes[idx]);
|
|
4738
4751
|
}
|
|
4739
4752
|
containerItemKeys.set(id, containerIndex);
|
|
4753
|
+
(_p = state.userScrollAnchorResetKeys) == null ? void 0 : _p.add(id);
|
|
4740
4754
|
const containerSticky = `containerSticky${containerIndex}`;
|
|
4741
4755
|
const isSticky = stickyIndicesSet.has(i);
|
|
4742
4756
|
const isAlwaysRender = alwaysRenderSet.has(i);
|
|
@@ -4764,10 +4778,13 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4764
4778
|
}
|
|
4765
4779
|
}
|
|
4766
4780
|
}
|
|
4781
|
+
if (((_q = state.userScrollAnchorResetKeys) == null ? void 0 : _q.size) === 0) {
|
|
4782
|
+
state.userScrollAnchorResetKeys = void 0;
|
|
4783
|
+
}
|
|
4767
4784
|
if (alwaysRenderArr.length > 0) {
|
|
4768
4785
|
for (const index of alwaysRenderArr) {
|
|
4769
4786
|
if (index < 0 || index >= dataLength) continue;
|
|
4770
|
-
const id = (
|
|
4787
|
+
const id = (_r = idCache[index]) != null ? _r : getId(state, index);
|
|
4771
4788
|
const containerIndex = containerItemKeys.get(id);
|
|
4772
4789
|
if (containerIndex !== void 0) {
|
|
4773
4790
|
state.stickyContainerPool.add(containerIndex);
|
|
@@ -5128,7 +5145,14 @@ function updateScroll(ctx, newScroll, forceUpdate) {
|
|
|
5128
5145
|
(_a4 = state.triggerCalculateItemsInView) == null ? void 0 : _a4.call(state, { doMVCP: scrollingTo !== void 0 });
|
|
5129
5146
|
checkThresholds(ctx);
|
|
5130
5147
|
};
|
|
5131
|
-
if (scrollLength > 0 && scrollingTo === void 0 && scrollDelta > scrollLength) {
|
|
5148
|
+
if (scrollLength > 0 && scrollingTo === void 0 && scrollDelta > scrollLength && !state.pendingNativeMVCPAdjust) {
|
|
5149
|
+
state.mvcpAnchorLock = void 0;
|
|
5150
|
+
state.pendingNativeMVCPAdjust = void 0;
|
|
5151
|
+
state.userScrollAnchorResetKeys = /* @__PURE__ */ new Set();
|
|
5152
|
+
if (state.queuedMVCPRecalculate !== void 0) {
|
|
5153
|
+
cancelAnimationFrame(state.queuedMVCPRecalculate);
|
|
5154
|
+
state.queuedMVCPRecalculate = void 0;
|
|
5155
|
+
}
|
|
5132
5156
|
ReactDOM.flushSync(runCalculateItems);
|
|
5133
5157
|
} else {
|
|
5134
5158
|
runCalculateItems();
|
|
@@ -5311,6 +5335,20 @@ function maybeUpdateAnchoredEndSpace(ctx) {
|
|
|
5311
5335
|
// src/core/updateItemSize.ts
|
|
5312
5336
|
function runOrScheduleMVCPRecalculate(ctx) {
|
|
5313
5337
|
const state = ctx.state;
|
|
5338
|
+
if (state.userScrollAnchorResetKeys !== void 0) {
|
|
5339
|
+
if (state.queuedMVCPRecalculate !== void 0) {
|
|
5340
|
+
return;
|
|
5341
|
+
}
|
|
5342
|
+
state.queuedMVCPRecalculate = requestAnimationFrame(() => {
|
|
5343
|
+
var _a3;
|
|
5344
|
+
state.queuedMVCPRecalculate = void 0;
|
|
5345
|
+
calculateItemsInView(ctx);
|
|
5346
|
+
if (((_a3 = state.userScrollAnchorResetKeys) == null ? void 0 : _a3.size) === 0) {
|
|
5347
|
+
state.userScrollAnchorResetKeys = void 0;
|
|
5348
|
+
}
|
|
5349
|
+
});
|
|
5350
|
+
return;
|
|
5351
|
+
}
|
|
5314
5352
|
{
|
|
5315
5353
|
if (!state.mvcpAnchorLock) {
|
|
5316
5354
|
if (state.queuedMVCPRecalculate !== void 0) {
|
|
@@ -5332,6 +5370,8 @@ function runOrScheduleMVCPRecalculate(ctx) {
|
|
|
5332
5370
|
function updateItemSize(ctx, itemKey, sizeObj) {
|
|
5333
5371
|
var _a3;
|
|
5334
5372
|
const state = ctx.state;
|
|
5373
|
+
const userScrollAnchorResetKeys = state.userScrollAnchorResetKeys;
|
|
5374
|
+
const didMeasureUserScrollAnchorResetItem = !!(userScrollAnchorResetKeys == null ? void 0 : userScrollAnchorResetKeys.delete(itemKey));
|
|
5335
5375
|
const {
|
|
5336
5376
|
didContainersLayout,
|
|
5337
5377
|
sizesKnown,
|
|
@@ -5410,10 +5450,12 @@ function updateItemSize(ctx, itemKey, sizeObj) {
|
|
|
5410
5450
|
if (!cur || maxOtherAxisSize > cur) {
|
|
5411
5451
|
set$(ctx, "otherAxisSize", maxOtherAxisSize);
|
|
5412
5452
|
}
|
|
5413
|
-
if (didContainersLayout || checkAllSizesKnown(state)) {
|
|
5453
|
+
if (didContainersLayout || checkAllSizesKnown(state, getMountedBufferedIndices(state))) {
|
|
5414
5454
|
if (needsRecalculate) {
|
|
5415
5455
|
state.scrollForNextCalculateItemsInView = void 0;
|
|
5416
5456
|
runOrScheduleMVCPRecalculate(ctx);
|
|
5457
|
+
} else if (didMeasureUserScrollAnchorResetItem && (userScrollAnchorResetKeys == null ? void 0 : userScrollAnchorResetKeys.size) === 0) {
|
|
5458
|
+
state.userScrollAnchorResetKeys = void 0;
|
|
5417
5459
|
}
|
|
5418
5460
|
if (shouldMaintainScrollAtEnd) {
|
|
5419
5461
|
if (maintainScrollAtEnd == null ? void 0 : maintainScrollAtEnd.onItemLayout) {
|
package/index.mjs
CHANGED
|
@@ -2059,7 +2059,7 @@ function getId(state, index) {
|
|
|
2059
2059
|
}
|
|
2060
2060
|
|
|
2061
2061
|
// src/core/addTotalSize.ts
|
|
2062
|
-
function addTotalSize(ctx, key, add) {
|
|
2062
|
+
function addTotalSize(ctx, key, add, notifyTotalSize = true) {
|
|
2063
2063
|
const state = ctx.state;
|
|
2064
2064
|
const prevTotalSize = state.totalSize;
|
|
2065
2065
|
let totalSize = state.totalSize;
|
|
@@ -2076,25 +2076,29 @@ function addTotalSize(ctx, key, add) {
|
|
|
2076
2076
|
{
|
|
2077
2077
|
state.pendingTotalSize = void 0;
|
|
2078
2078
|
state.totalSize = totalSize;
|
|
2079
|
-
|
|
2079
|
+
if (notifyTotalSize) {
|
|
2080
|
+
set$(ctx, "totalSize", totalSize);
|
|
2081
|
+
}
|
|
2080
2082
|
}
|
|
2083
|
+
} else if (notifyTotalSize && ctx.values.get("totalSize") !== totalSize) {
|
|
2084
|
+
set$(ctx, "totalSize", totalSize);
|
|
2081
2085
|
}
|
|
2082
2086
|
}
|
|
2083
2087
|
|
|
2084
2088
|
// src/core/setSize.ts
|
|
2085
|
-
function setSize(ctx, itemKey, size) {
|
|
2089
|
+
function setSize(ctx, itemKey, size, notifyTotalSize = true) {
|
|
2086
2090
|
const state = ctx.state;
|
|
2087
2091
|
const { sizes } = state;
|
|
2088
2092
|
const previousSize = sizes.get(itemKey);
|
|
2089
2093
|
const diff = previousSize !== void 0 ? size - previousSize : size;
|
|
2090
2094
|
if (diff !== 0) {
|
|
2091
|
-
addTotalSize(ctx, itemKey, diff);
|
|
2095
|
+
addTotalSize(ctx, itemKey, diff, notifyTotalSize);
|
|
2092
2096
|
}
|
|
2093
2097
|
sizes.set(itemKey, size);
|
|
2094
2098
|
}
|
|
2095
2099
|
|
|
2096
2100
|
// src/utils/getItemSize.ts
|
|
2097
|
-
function getItemSize(ctx, key, index, data, useAverageSize, preferCachedSize) {
|
|
2101
|
+
function getItemSize(ctx, key, index, data, useAverageSize, preferCachedSize, notifyTotalSize) {
|
|
2098
2102
|
var _a3, _b, _c;
|
|
2099
2103
|
const state = ctx.state;
|
|
2100
2104
|
const {
|
|
@@ -2140,7 +2144,7 @@ function getItemSize(ctx, key, index, data, useAverageSize, preferCachedSize) {
|
|
|
2140
2144
|
if (size === void 0) {
|
|
2141
2145
|
size = getEstimatedItemSize ? getEstimatedItemSize(data, index, itemType) : estimatedItemSize;
|
|
2142
2146
|
}
|
|
2143
|
-
setSize(ctx, key, size);
|
|
2147
|
+
setSize(ctx, key, size, notifyTotalSize);
|
|
2144
2148
|
return size;
|
|
2145
2149
|
}
|
|
2146
2150
|
function getItemSizeAtIndex(ctx, index) {
|
|
@@ -2579,10 +2583,10 @@ function getMountedBufferedIndices(state) {
|
|
|
2579
2583
|
function getMountedNoBufferIndices(state) {
|
|
2580
2584
|
return getMountedIndicesInRange(state, state.startNoBuffer, state.endNoBuffer);
|
|
2581
2585
|
}
|
|
2582
|
-
function checkAllSizesKnown(state, indices
|
|
2586
|
+
function checkAllSizesKnown(state, indices) {
|
|
2583
2587
|
return indices.length > 0 && indices.every((index) => {
|
|
2584
2588
|
const key = getId(state, index);
|
|
2585
|
-
return state.sizesKnown.has(key);
|
|
2589
|
+
return key !== void 0 && state.sizesKnown.has(key);
|
|
2586
2590
|
});
|
|
2587
2591
|
}
|
|
2588
2592
|
|
|
@@ -3892,6 +3896,7 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
|
|
|
3892
3896
|
const maxVisibleArea = scrollBottomBuffered + 1e3;
|
|
3893
3897
|
const useAverageSize = !getEstimatedItemSize;
|
|
3894
3898
|
const preferCachedSize = !doMVCP || dataChanged || state.scrollAdjustHandler.getAdjust() !== 0 || ((_b = peek$(ctx, "scrollAdjustPending")) != null ? _b : 0) !== 0;
|
|
3899
|
+
const notifyTotalSizeWhileCachingSizes = false;
|
|
3895
3900
|
let currentRowTop = 0;
|
|
3896
3901
|
let column = 1;
|
|
3897
3902
|
let maxSizeInRow = 0;
|
|
@@ -3919,7 +3924,15 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
|
|
|
3919
3924
|
const prevIndex = startIndex - 1;
|
|
3920
3925
|
const prevId = getId(state, prevIndex);
|
|
3921
3926
|
const prevPosition = (_c = positions[prevIndex]) != null ? _c : 0;
|
|
3922
|
-
const prevSize = (_d = sizesKnown.get(prevId)) != null ? _d : getItemSize(
|
|
3927
|
+
const prevSize = (_d = sizesKnown.get(prevId)) != null ? _d : getItemSize(
|
|
3928
|
+
ctx,
|
|
3929
|
+
prevId,
|
|
3930
|
+
prevIndex,
|
|
3931
|
+
data[prevIndex],
|
|
3932
|
+
useAverageSize,
|
|
3933
|
+
preferCachedSize,
|
|
3934
|
+
notifyTotalSizeWhileCachingSizes
|
|
3935
|
+
);
|
|
3923
3936
|
currentRowTop = prevPosition + prevSize;
|
|
3924
3937
|
}
|
|
3925
3938
|
}
|
|
@@ -3952,7 +3965,7 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
|
|
|
3952
3965
|
maxSizeInRow = 0;
|
|
3953
3966
|
}
|
|
3954
3967
|
const knownSize = sizesKnown.get(id);
|
|
3955
|
-
const size = knownSize !== void 0 ? knownSize : getItemSize(ctx, id, i, data[i], useAverageSize, preferCachedSize);
|
|
3968
|
+
const size = knownSize !== void 0 ? knownSize : getItemSize(ctx, id, i, data[i], useAverageSize, preferCachedSize, notifyTotalSizeWhileCachingSizes);
|
|
3956
3969
|
if (IS_DEV && needsIndexByKey) {
|
|
3957
3970
|
if (indexByKeyForChecking.has(id)) {
|
|
3958
3971
|
console.error(
|
|
@@ -4427,7 +4440,7 @@ function handleStickyRecycling(ctx, stickyArray, scroll, drawDistance, currentSt
|
|
|
4427
4440
|
function calculateItemsInView(ctx, params = {}) {
|
|
4428
4441
|
const state = ctx.state;
|
|
4429
4442
|
batchedUpdates(() => {
|
|
4430
|
-
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
4443
|
+
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
4431
4444
|
const {
|
|
4432
4445
|
columns,
|
|
4433
4446
|
columnSpans,
|
|
@@ -4716,6 +4729,7 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4716
4729
|
state.containerItemTypes.set(containerIndex, requiredItemTypes[idx]);
|
|
4717
4730
|
}
|
|
4718
4731
|
containerItemKeys.set(id, containerIndex);
|
|
4732
|
+
(_p = state.userScrollAnchorResetKeys) == null ? void 0 : _p.add(id);
|
|
4719
4733
|
const containerSticky = `containerSticky${containerIndex}`;
|
|
4720
4734
|
const isSticky = stickyIndicesSet.has(i);
|
|
4721
4735
|
const isAlwaysRender = alwaysRenderSet.has(i);
|
|
@@ -4743,10 +4757,13 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4743
4757
|
}
|
|
4744
4758
|
}
|
|
4745
4759
|
}
|
|
4760
|
+
if (((_q = state.userScrollAnchorResetKeys) == null ? void 0 : _q.size) === 0) {
|
|
4761
|
+
state.userScrollAnchorResetKeys = void 0;
|
|
4762
|
+
}
|
|
4746
4763
|
if (alwaysRenderArr.length > 0) {
|
|
4747
4764
|
for (const index of alwaysRenderArr) {
|
|
4748
4765
|
if (index < 0 || index >= dataLength) continue;
|
|
4749
|
-
const id = (
|
|
4766
|
+
const id = (_r = idCache[index]) != null ? _r : getId(state, index);
|
|
4750
4767
|
const containerIndex = containerItemKeys.get(id);
|
|
4751
4768
|
if (containerIndex !== void 0) {
|
|
4752
4769
|
state.stickyContainerPool.add(containerIndex);
|
|
@@ -5107,7 +5124,14 @@ function updateScroll(ctx, newScroll, forceUpdate) {
|
|
|
5107
5124
|
(_a4 = state.triggerCalculateItemsInView) == null ? void 0 : _a4.call(state, { doMVCP: scrollingTo !== void 0 });
|
|
5108
5125
|
checkThresholds(ctx);
|
|
5109
5126
|
};
|
|
5110
|
-
if (scrollLength > 0 && scrollingTo === void 0 && scrollDelta > scrollLength) {
|
|
5127
|
+
if (scrollLength > 0 && scrollingTo === void 0 && scrollDelta > scrollLength && !state.pendingNativeMVCPAdjust) {
|
|
5128
|
+
state.mvcpAnchorLock = void 0;
|
|
5129
|
+
state.pendingNativeMVCPAdjust = void 0;
|
|
5130
|
+
state.userScrollAnchorResetKeys = /* @__PURE__ */ new Set();
|
|
5131
|
+
if (state.queuedMVCPRecalculate !== void 0) {
|
|
5132
|
+
cancelAnimationFrame(state.queuedMVCPRecalculate);
|
|
5133
|
+
state.queuedMVCPRecalculate = void 0;
|
|
5134
|
+
}
|
|
5111
5135
|
flushSync(runCalculateItems);
|
|
5112
5136
|
} else {
|
|
5113
5137
|
runCalculateItems();
|
|
@@ -5290,6 +5314,20 @@ function maybeUpdateAnchoredEndSpace(ctx) {
|
|
|
5290
5314
|
// src/core/updateItemSize.ts
|
|
5291
5315
|
function runOrScheduleMVCPRecalculate(ctx) {
|
|
5292
5316
|
const state = ctx.state;
|
|
5317
|
+
if (state.userScrollAnchorResetKeys !== void 0) {
|
|
5318
|
+
if (state.queuedMVCPRecalculate !== void 0) {
|
|
5319
|
+
return;
|
|
5320
|
+
}
|
|
5321
|
+
state.queuedMVCPRecalculate = requestAnimationFrame(() => {
|
|
5322
|
+
var _a3;
|
|
5323
|
+
state.queuedMVCPRecalculate = void 0;
|
|
5324
|
+
calculateItemsInView(ctx);
|
|
5325
|
+
if (((_a3 = state.userScrollAnchorResetKeys) == null ? void 0 : _a3.size) === 0) {
|
|
5326
|
+
state.userScrollAnchorResetKeys = void 0;
|
|
5327
|
+
}
|
|
5328
|
+
});
|
|
5329
|
+
return;
|
|
5330
|
+
}
|
|
5293
5331
|
{
|
|
5294
5332
|
if (!state.mvcpAnchorLock) {
|
|
5295
5333
|
if (state.queuedMVCPRecalculate !== void 0) {
|
|
@@ -5311,6 +5349,8 @@ function runOrScheduleMVCPRecalculate(ctx) {
|
|
|
5311
5349
|
function updateItemSize(ctx, itemKey, sizeObj) {
|
|
5312
5350
|
var _a3;
|
|
5313
5351
|
const state = ctx.state;
|
|
5352
|
+
const userScrollAnchorResetKeys = state.userScrollAnchorResetKeys;
|
|
5353
|
+
const didMeasureUserScrollAnchorResetItem = !!(userScrollAnchorResetKeys == null ? void 0 : userScrollAnchorResetKeys.delete(itemKey));
|
|
5314
5354
|
const {
|
|
5315
5355
|
didContainersLayout,
|
|
5316
5356
|
sizesKnown,
|
|
@@ -5389,10 +5429,12 @@ function updateItemSize(ctx, itemKey, sizeObj) {
|
|
|
5389
5429
|
if (!cur || maxOtherAxisSize > cur) {
|
|
5390
5430
|
set$(ctx, "otherAxisSize", maxOtherAxisSize);
|
|
5391
5431
|
}
|
|
5392
|
-
if (didContainersLayout || checkAllSizesKnown(state)) {
|
|
5432
|
+
if (didContainersLayout || checkAllSizesKnown(state, getMountedBufferedIndices(state))) {
|
|
5393
5433
|
if (needsRecalculate) {
|
|
5394
5434
|
state.scrollForNextCalculateItemsInView = void 0;
|
|
5395
5435
|
runOrScheduleMVCPRecalculate(ctx);
|
|
5436
|
+
} else if (didMeasureUserScrollAnchorResetItem && (userScrollAnchorResetKeys == null ? void 0 : userScrollAnchorResetKeys.size) === 0) {
|
|
5437
|
+
state.userScrollAnchorResetKeys = void 0;
|
|
5396
5438
|
}
|
|
5397
5439
|
if (shouldMaintainScrollAtEnd) {
|
|
5398
5440
|
if (maintainScrollAtEnd == null ? void 0 : maintainScrollAtEnd.onItemLayout) {
|
package/index.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) {
|