@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/react-native.web.js
CHANGED
|
@@ -2083,7 +2083,7 @@ function getId(state, index) {
|
|
|
2083
2083
|
}
|
|
2084
2084
|
|
|
2085
2085
|
// src/core/addTotalSize.ts
|
|
2086
|
-
function addTotalSize(ctx, key, add) {
|
|
2086
|
+
function addTotalSize(ctx, key, add, notifyTotalSize = true) {
|
|
2087
2087
|
const state = ctx.state;
|
|
2088
2088
|
const prevTotalSize = state.totalSize;
|
|
2089
2089
|
let totalSize = state.totalSize;
|
|
@@ -2100,25 +2100,29 @@ function addTotalSize(ctx, key, add) {
|
|
|
2100
2100
|
{
|
|
2101
2101
|
state.pendingTotalSize = void 0;
|
|
2102
2102
|
state.totalSize = totalSize;
|
|
2103
|
-
|
|
2103
|
+
if (notifyTotalSize) {
|
|
2104
|
+
set$(ctx, "totalSize", totalSize);
|
|
2105
|
+
}
|
|
2104
2106
|
}
|
|
2107
|
+
} else if (notifyTotalSize && ctx.values.get("totalSize") !== totalSize) {
|
|
2108
|
+
set$(ctx, "totalSize", totalSize);
|
|
2105
2109
|
}
|
|
2106
2110
|
}
|
|
2107
2111
|
|
|
2108
2112
|
// src/core/setSize.ts
|
|
2109
|
-
function setSize(ctx, itemKey, size) {
|
|
2113
|
+
function setSize(ctx, itemKey, size, notifyTotalSize = true) {
|
|
2110
2114
|
const state = ctx.state;
|
|
2111
2115
|
const { sizes } = state;
|
|
2112
2116
|
const previousSize = sizes.get(itemKey);
|
|
2113
2117
|
const diff = previousSize !== void 0 ? size - previousSize : size;
|
|
2114
2118
|
if (diff !== 0) {
|
|
2115
|
-
addTotalSize(ctx, itemKey, diff);
|
|
2119
|
+
addTotalSize(ctx, itemKey, diff, notifyTotalSize);
|
|
2116
2120
|
}
|
|
2117
2121
|
sizes.set(itemKey, size);
|
|
2118
2122
|
}
|
|
2119
2123
|
|
|
2120
2124
|
// src/utils/getItemSize.ts
|
|
2121
|
-
function getItemSize(ctx, key, index, data, useAverageSize, preferCachedSize) {
|
|
2125
|
+
function getItemSize(ctx, key, index, data, useAverageSize, preferCachedSize, notifyTotalSize) {
|
|
2122
2126
|
var _a3, _b, _c;
|
|
2123
2127
|
const state = ctx.state;
|
|
2124
2128
|
const {
|
|
@@ -2164,7 +2168,7 @@ function getItemSize(ctx, key, index, data, useAverageSize, preferCachedSize) {
|
|
|
2164
2168
|
if (size === void 0) {
|
|
2165
2169
|
size = getEstimatedItemSize ? getEstimatedItemSize(data, index, itemType) : estimatedItemSize;
|
|
2166
2170
|
}
|
|
2167
|
-
setSize(ctx, key, size);
|
|
2171
|
+
setSize(ctx, key, size, notifyTotalSize);
|
|
2168
2172
|
return size;
|
|
2169
2173
|
}
|
|
2170
2174
|
function getItemSizeAtIndex(ctx, index) {
|
|
@@ -2603,10 +2607,10 @@ function getMountedBufferedIndices(state) {
|
|
|
2603
2607
|
function getMountedNoBufferIndices(state) {
|
|
2604
2608
|
return getMountedIndicesInRange(state, state.startNoBuffer, state.endNoBuffer);
|
|
2605
2609
|
}
|
|
2606
|
-
function checkAllSizesKnown(state, indices
|
|
2610
|
+
function checkAllSizesKnown(state, indices) {
|
|
2607
2611
|
return indices.length > 0 && indices.every((index) => {
|
|
2608
2612
|
const key = getId(state, index);
|
|
2609
|
-
return state.sizesKnown.has(key);
|
|
2613
|
+
return key !== void 0 && state.sizesKnown.has(key);
|
|
2610
2614
|
});
|
|
2611
2615
|
}
|
|
2612
2616
|
|
|
@@ -3916,6 +3920,7 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
|
|
|
3916
3920
|
const maxVisibleArea = scrollBottomBuffered + 1e3;
|
|
3917
3921
|
const useAverageSize = !getEstimatedItemSize;
|
|
3918
3922
|
const preferCachedSize = !doMVCP || dataChanged || state.scrollAdjustHandler.getAdjust() !== 0 || ((_b = peek$(ctx, "scrollAdjustPending")) != null ? _b : 0) !== 0;
|
|
3923
|
+
const notifyTotalSizeWhileCachingSizes = false;
|
|
3919
3924
|
let currentRowTop = 0;
|
|
3920
3925
|
let column = 1;
|
|
3921
3926
|
let maxSizeInRow = 0;
|
|
@@ -3943,7 +3948,15 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
|
|
|
3943
3948
|
const prevIndex = startIndex - 1;
|
|
3944
3949
|
const prevId = getId(state, prevIndex);
|
|
3945
3950
|
const prevPosition = (_c = positions[prevIndex]) != null ? _c : 0;
|
|
3946
|
-
const prevSize = (_d = sizesKnown.get(prevId)) != null ? _d : getItemSize(
|
|
3951
|
+
const prevSize = (_d = sizesKnown.get(prevId)) != null ? _d : getItemSize(
|
|
3952
|
+
ctx,
|
|
3953
|
+
prevId,
|
|
3954
|
+
prevIndex,
|
|
3955
|
+
data[prevIndex],
|
|
3956
|
+
useAverageSize,
|
|
3957
|
+
preferCachedSize,
|
|
3958
|
+
notifyTotalSizeWhileCachingSizes
|
|
3959
|
+
);
|
|
3947
3960
|
currentRowTop = prevPosition + prevSize;
|
|
3948
3961
|
}
|
|
3949
3962
|
}
|
|
@@ -3976,7 +3989,7 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
|
|
|
3976
3989
|
maxSizeInRow = 0;
|
|
3977
3990
|
}
|
|
3978
3991
|
const knownSize = sizesKnown.get(id);
|
|
3979
|
-
const size = knownSize !== void 0 ? knownSize : getItemSize(ctx, id, i, data[i], useAverageSize, preferCachedSize);
|
|
3992
|
+
const size = knownSize !== void 0 ? knownSize : getItemSize(ctx, id, i, data[i], useAverageSize, preferCachedSize, notifyTotalSizeWhileCachingSizes);
|
|
3980
3993
|
if (IS_DEV && needsIndexByKey) {
|
|
3981
3994
|
if (indexByKeyForChecking.has(id)) {
|
|
3982
3995
|
console.error(
|
|
@@ -4451,7 +4464,7 @@ function handleStickyRecycling(ctx, stickyArray, scroll, drawDistance, currentSt
|
|
|
4451
4464
|
function calculateItemsInView(ctx, params = {}) {
|
|
4452
4465
|
const state = ctx.state;
|
|
4453
4466
|
batchedUpdates(() => {
|
|
4454
|
-
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
4467
|
+
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
4455
4468
|
const {
|
|
4456
4469
|
columns,
|
|
4457
4470
|
columnSpans,
|
|
@@ -4740,6 +4753,7 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4740
4753
|
state.containerItemTypes.set(containerIndex, requiredItemTypes[idx]);
|
|
4741
4754
|
}
|
|
4742
4755
|
containerItemKeys.set(id, containerIndex);
|
|
4756
|
+
(_p = state.userScrollAnchorResetKeys) == null ? void 0 : _p.add(id);
|
|
4743
4757
|
const containerSticky = `containerSticky${containerIndex}`;
|
|
4744
4758
|
const isSticky = stickyIndicesSet.has(i);
|
|
4745
4759
|
const isAlwaysRender = alwaysRenderSet.has(i);
|
|
@@ -4767,10 +4781,13 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4767
4781
|
}
|
|
4768
4782
|
}
|
|
4769
4783
|
}
|
|
4784
|
+
if (((_q = state.userScrollAnchorResetKeys) == null ? void 0 : _q.size) === 0) {
|
|
4785
|
+
state.userScrollAnchorResetKeys = void 0;
|
|
4786
|
+
}
|
|
4770
4787
|
if (alwaysRenderArr.length > 0) {
|
|
4771
4788
|
for (const index of alwaysRenderArr) {
|
|
4772
4789
|
if (index < 0 || index >= dataLength) continue;
|
|
4773
|
-
const id = (
|
|
4790
|
+
const id = (_r = idCache[index]) != null ? _r : getId(state, index);
|
|
4774
4791
|
const containerIndex = containerItemKeys.get(id);
|
|
4775
4792
|
if (containerIndex !== void 0) {
|
|
4776
4793
|
state.stickyContainerPool.add(containerIndex);
|
|
@@ -5131,7 +5148,14 @@ function updateScroll(ctx, newScroll, forceUpdate) {
|
|
|
5131
5148
|
(_a4 = state.triggerCalculateItemsInView) == null ? void 0 : _a4.call(state, { doMVCP: scrollingTo !== void 0 });
|
|
5132
5149
|
checkThresholds(ctx);
|
|
5133
5150
|
};
|
|
5134
|
-
if (scrollLength > 0 && scrollingTo === void 0 && scrollDelta > scrollLength) {
|
|
5151
|
+
if (scrollLength > 0 && scrollingTo === void 0 && scrollDelta > scrollLength && !state.pendingNativeMVCPAdjust) {
|
|
5152
|
+
state.mvcpAnchorLock = void 0;
|
|
5153
|
+
state.pendingNativeMVCPAdjust = void 0;
|
|
5154
|
+
state.userScrollAnchorResetKeys = /* @__PURE__ */ new Set();
|
|
5155
|
+
if (state.queuedMVCPRecalculate !== void 0) {
|
|
5156
|
+
cancelAnimationFrame(state.queuedMVCPRecalculate);
|
|
5157
|
+
state.queuedMVCPRecalculate = void 0;
|
|
5158
|
+
}
|
|
5135
5159
|
ReactDOM.flushSync(runCalculateItems);
|
|
5136
5160
|
} else {
|
|
5137
5161
|
runCalculateItems();
|
|
@@ -5314,6 +5338,20 @@ function maybeUpdateAnchoredEndSpace(ctx) {
|
|
|
5314
5338
|
// src/core/updateItemSize.ts
|
|
5315
5339
|
function runOrScheduleMVCPRecalculate(ctx) {
|
|
5316
5340
|
const state = ctx.state;
|
|
5341
|
+
if (state.userScrollAnchorResetKeys !== void 0) {
|
|
5342
|
+
if (state.queuedMVCPRecalculate !== void 0) {
|
|
5343
|
+
return;
|
|
5344
|
+
}
|
|
5345
|
+
state.queuedMVCPRecalculate = requestAnimationFrame(() => {
|
|
5346
|
+
var _a3;
|
|
5347
|
+
state.queuedMVCPRecalculate = void 0;
|
|
5348
|
+
calculateItemsInView(ctx);
|
|
5349
|
+
if (((_a3 = state.userScrollAnchorResetKeys) == null ? void 0 : _a3.size) === 0) {
|
|
5350
|
+
state.userScrollAnchorResetKeys = void 0;
|
|
5351
|
+
}
|
|
5352
|
+
});
|
|
5353
|
+
return;
|
|
5354
|
+
}
|
|
5317
5355
|
{
|
|
5318
5356
|
if (!state.mvcpAnchorLock) {
|
|
5319
5357
|
if (state.queuedMVCPRecalculate !== void 0) {
|
|
@@ -5335,6 +5373,8 @@ function runOrScheduleMVCPRecalculate(ctx) {
|
|
|
5335
5373
|
function updateItemSize(ctx, itemKey, sizeObj) {
|
|
5336
5374
|
var _a3;
|
|
5337
5375
|
const state = ctx.state;
|
|
5376
|
+
const userScrollAnchorResetKeys = state.userScrollAnchorResetKeys;
|
|
5377
|
+
const didMeasureUserScrollAnchorResetItem = !!(userScrollAnchorResetKeys == null ? void 0 : userScrollAnchorResetKeys.delete(itemKey));
|
|
5338
5378
|
const {
|
|
5339
5379
|
didContainersLayout,
|
|
5340
5380
|
sizesKnown,
|
|
@@ -5413,10 +5453,12 @@ function updateItemSize(ctx, itemKey, sizeObj) {
|
|
|
5413
5453
|
if (!cur || maxOtherAxisSize > cur) {
|
|
5414
5454
|
set$(ctx, "otherAxisSize", maxOtherAxisSize);
|
|
5415
5455
|
}
|
|
5416
|
-
if (didContainersLayout || checkAllSizesKnown(state)) {
|
|
5456
|
+
if (didContainersLayout || checkAllSizesKnown(state, getMountedBufferedIndices(state))) {
|
|
5417
5457
|
if (needsRecalculate) {
|
|
5418
5458
|
state.scrollForNextCalculateItemsInView = void 0;
|
|
5419
5459
|
runOrScheduleMVCPRecalculate(ctx);
|
|
5460
|
+
} else if (didMeasureUserScrollAnchorResetItem && (userScrollAnchorResetKeys == null ? void 0 : userScrollAnchorResetKeys.size) === 0) {
|
|
5461
|
+
state.userScrollAnchorResetKeys = void 0;
|
|
5420
5462
|
}
|
|
5421
5463
|
if (shouldMaintainScrollAtEnd) {
|
|
5422
5464
|
if (maintainScrollAtEnd == null ? void 0 : maintainScrollAtEnd.onItemLayout) {
|
package/react-native.web.mjs
CHANGED
|
@@ -2062,7 +2062,7 @@ function getId(state, index) {
|
|
|
2062
2062
|
}
|
|
2063
2063
|
|
|
2064
2064
|
// src/core/addTotalSize.ts
|
|
2065
|
-
function addTotalSize(ctx, key, add) {
|
|
2065
|
+
function addTotalSize(ctx, key, add, notifyTotalSize = true) {
|
|
2066
2066
|
const state = ctx.state;
|
|
2067
2067
|
const prevTotalSize = state.totalSize;
|
|
2068
2068
|
let totalSize = state.totalSize;
|
|
@@ -2079,25 +2079,29 @@ function addTotalSize(ctx, key, add) {
|
|
|
2079
2079
|
{
|
|
2080
2080
|
state.pendingTotalSize = void 0;
|
|
2081
2081
|
state.totalSize = totalSize;
|
|
2082
|
-
|
|
2082
|
+
if (notifyTotalSize) {
|
|
2083
|
+
set$(ctx, "totalSize", totalSize);
|
|
2084
|
+
}
|
|
2083
2085
|
}
|
|
2086
|
+
} else if (notifyTotalSize && ctx.values.get("totalSize") !== totalSize) {
|
|
2087
|
+
set$(ctx, "totalSize", totalSize);
|
|
2084
2088
|
}
|
|
2085
2089
|
}
|
|
2086
2090
|
|
|
2087
2091
|
// src/core/setSize.ts
|
|
2088
|
-
function setSize(ctx, itemKey, size) {
|
|
2092
|
+
function setSize(ctx, itemKey, size, notifyTotalSize = true) {
|
|
2089
2093
|
const state = ctx.state;
|
|
2090
2094
|
const { sizes } = state;
|
|
2091
2095
|
const previousSize = sizes.get(itemKey);
|
|
2092
2096
|
const diff = previousSize !== void 0 ? size - previousSize : size;
|
|
2093
2097
|
if (diff !== 0) {
|
|
2094
|
-
addTotalSize(ctx, itemKey, diff);
|
|
2098
|
+
addTotalSize(ctx, itemKey, diff, notifyTotalSize);
|
|
2095
2099
|
}
|
|
2096
2100
|
sizes.set(itemKey, size);
|
|
2097
2101
|
}
|
|
2098
2102
|
|
|
2099
2103
|
// src/utils/getItemSize.ts
|
|
2100
|
-
function getItemSize(ctx, key, index, data, useAverageSize, preferCachedSize) {
|
|
2104
|
+
function getItemSize(ctx, key, index, data, useAverageSize, preferCachedSize, notifyTotalSize) {
|
|
2101
2105
|
var _a3, _b, _c;
|
|
2102
2106
|
const state = ctx.state;
|
|
2103
2107
|
const {
|
|
@@ -2143,7 +2147,7 @@ function getItemSize(ctx, key, index, data, useAverageSize, preferCachedSize) {
|
|
|
2143
2147
|
if (size === void 0) {
|
|
2144
2148
|
size = getEstimatedItemSize ? getEstimatedItemSize(data, index, itemType) : estimatedItemSize;
|
|
2145
2149
|
}
|
|
2146
|
-
setSize(ctx, key, size);
|
|
2150
|
+
setSize(ctx, key, size, notifyTotalSize);
|
|
2147
2151
|
return size;
|
|
2148
2152
|
}
|
|
2149
2153
|
function getItemSizeAtIndex(ctx, index) {
|
|
@@ -2582,10 +2586,10 @@ function getMountedBufferedIndices(state) {
|
|
|
2582
2586
|
function getMountedNoBufferIndices(state) {
|
|
2583
2587
|
return getMountedIndicesInRange(state, state.startNoBuffer, state.endNoBuffer);
|
|
2584
2588
|
}
|
|
2585
|
-
function checkAllSizesKnown(state, indices
|
|
2589
|
+
function checkAllSizesKnown(state, indices) {
|
|
2586
2590
|
return indices.length > 0 && indices.every((index) => {
|
|
2587
2591
|
const key = getId(state, index);
|
|
2588
|
-
return state.sizesKnown.has(key);
|
|
2592
|
+
return key !== void 0 && state.sizesKnown.has(key);
|
|
2589
2593
|
});
|
|
2590
2594
|
}
|
|
2591
2595
|
|
|
@@ -3895,6 +3899,7 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
|
|
|
3895
3899
|
const maxVisibleArea = scrollBottomBuffered + 1e3;
|
|
3896
3900
|
const useAverageSize = !getEstimatedItemSize;
|
|
3897
3901
|
const preferCachedSize = !doMVCP || dataChanged || state.scrollAdjustHandler.getAdjust() !== 0 || ((_b = peek$(ctx, "scrollAdjustPending")) != null ? _b : 0) !== 0;
|
|
3902
|
+
const notifyTotalSizeWhileCachingSizes = false;
|
|
3898
3903
|
let currentRowTop = 0;
|
|
3899
3904
|
let column = 1;
|
|
3900
3905
|
let maxSizeInRow = 0;
|
|
@@ -3922,7 +3927,15 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
|
|
|
3922
3927
|
const prevIndex = startIndex - 1;
|
|
3923
3928
|
const prevId = getId(state, prevIndex);
|
|
3924
3929
|
const prevPosition = (_c = positions[prevIndex]) != null ? _c : 0;
|
|
3925
|
-
const prevSize = (_d = sizesKnown.get(prevId)) != null ? _d : getItemSize(
|
|
3930
|
+
const prevSize = (_d = sizesKnown.get(prevId)) != null ? _d : getItemSize(
|
|
3931
|
+
ctx,
|
|
3932
|
+
prevId,
|
|
3933
|
+
prevIndex,
|
|
3934
|
+
data[prevIndex],
|
|
3935
|
+
useAverageSize,
|
|
3936
|
+
preferCachedSize,
|
|
3937
|
+
notifyTotalSizeWhileCachingSizes
|
|
3938
|
+
);
|
|
3926
3939
|
currentRowTop = prevPosition + prevSize;
|
|
3927
3940
|
}
|
|
3928
3941
|
}
|
|
@@ -3955,7 +3968,7 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
|
|
|
3955
3968
|
maxSizeInRow = 0;
|
|
3956
3969
|
}
|
|
3957
3970
|
const knownSize = sizesKnown.get(id);
|
|
3958
|
-
const size = knownSize !== void 0 ? knownSize : getItemSize(ctx, id, i, data[i], useAverageSize, preferCachedSize);
|
|
3971
|
+
const size = knownSize !== void 0 ? knownSize : getItemSize(ctx, id, i, data[i], useAverageSize, preferCachedSize, notifyTotalSizeWhileCachingSizes);
|
|
3959
3972
|
if (IS_DEV && needsIndexByKey) {
|
|
3960
3973
|
if (indexByKeyForChecking.has(id)) {
|
|
3961
3974
|
console.error(
|
|
@@ -4430,7 +4443,7 @@ function handleStickyRecycling(ctx, stickyArray, scroll, drawDistance, currentSt
|
|
|
4430
4443
|
function calculateItemsInView(ctx, params = {}) {
|
|
4431
4444
|
const state = ctx.state;
|
|
4432
4445
|
batchedUpdates(() => {
|
|
4433
|
-
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
4446
|
+
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
4434
4447
|
const {
|
|
4435
4448
|
columns,
|
|
4436
4449
|
columnSpans,
|
|
@@ -4719,6 +4732,7 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4719
4732
|
state.containerItemTypes.set(containerIndex, requiredItemTypes[idx]);
|
|
4720
4733
|
}
|
|
4721
4734
|
containerItemKeys.set(id, containerIndex);
|
|
4735
|
+
(_p = state.userScrollAnchorResetKeys) == null ? void 0 : _p.add(id);
|
|
4722
4736
|
const containerSticky = `containerSticky${containerIndex}`;
|
|
4723
4737
|
const isSticky = stickyIndicesSet.has(i);
|
|
4724
4738
|
const isAlwaysRender = alwaysRenderSet.has(i);
|
|
@@ -4746,10 +4760,13 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4746
4760
|
}
|
|
4747
4761
|
}
|
|
4748
4762
|
}
|
|
4763
|
+
if (((_q = state.userScrollAnchorResetKeys) == null ? void 0 : _q.size) === 0) {
|
|
4764
|
+
state.userScrollAnchorResetKeys = void 0;
|
|
4765
|
+
}
|
|
4749
4766
|
if (alwaysRenderArr.length > 0) {
|
|
4750
4767
|
for (const index of alwaysRenderArr) {
|
|
4751
4768
|
if (index < 0 || index >= dataLength) continue;
|
|
4752
|
-
const id = (
|
|
4769
|
+
const id = (_r = idCache[index]) != null ? _r : getId(state, index);
|
|
4753
4770
|
const containerIndex = containerItemKeys.get(id);
|
|
4754
4771
|
if (containerIndex !== void 0) {
|
|
4755
4772
|
state.stickyContainerPool.add(containerIndex);
|
|
@@ -5110,7 +5127,14 @@ function updateScroll(ctx, newScroll, forceUpdate) {
|
|
|
5110
5127
|
(_a4 = state.triggerCalculateItemsInView) == null ? void 0 : _a4.call(state, { doMVCP: scrollingTo !== void 0 });
|
|
5111
5128
|
checkThresholds(ctx);
|
|
5112
5129
|
};
|
|
5113
|
-
if (scrollLength > 0 && scrollingTo === void 0 && scrollDelta > scrollLength) {
|
|
5130
|
+
if (scrollLength > 0 && scrollingTo === void 0 && scrollDelta > scrollLength && !state.pendingNativeMVCPAdjust) {
|
|
5131
|
+
state.mvcpAnchorLock = void 0;
|
|
5132
|
+
state.pendingNativeMVCPAdjust = void 0;
|
|
5133
|
+
state.userScrollAnchorResetKeys = /* @__PURE__ */ new Set();
|
|
5134
|
+
if (state.queuedMVCPRecalculate !== void 0) {
|
|
5135
|
+
cancelAnimationFrame(state.queuedMVCPRecalculate);
|
|
5136
|
+
state.queuedMVCPRecalculate = void 0;
|
|
5137
|
+
}
|
|
5114
5138
|
flushSync(runCalculateItems);
|
|
5115
5139
|
} else {
|
|
5116
5140
|
runCalculateItems();
|
|
@@ -5293,6 +5317,20 @@ function maybeUpdateAnchoredEndSpace(ctx) {
|
|
|
5293
5317
|
// src/core/updateItemSize.ts
|
|
5294
5318
|
function runOrScheduleMVCPRecalculate(ctx) {
|
|
5295
5319
|
const state = ctx.state;
|
|
5320
|
+
if (state.userScrollAnchorResetKeys !== void 0) {
|
|
5321
|
+
if (state.queuedMVCPRecalculate !== void 0) {
|
|
5322
|
+
return;
|
|
5323
|
+
}
|
|
5324
|
+
state.queuedMVCPRecalculate = requestAnimationFrame(() => {
|
|
5325
|
+
var _a3;
|
|
5326
|
+
state.queuedMVCPRecalculate = void 0;
|
|
5327
|
+
calculateItemsInView(ctx);
|
|
5328
|
+
if (((_a3 = state.userScrollAnchorResetKeys) == null ? void 0 : _a3.size) === 0) {
|
|
5329
|
+
state.userScrollAnchorResetKeys = void 0;
|
|
5330
|
+
}
|
|
5331
|
+
});
|
|
5332
|
+
return;
|
|
5333
|
+
}
|
|
5296
5334
|
{
|
|
5297
5335
|
if (!state.mvcpAnchorLock) {
|
|
5298
5336
|
if (state.queuedMVCPRecalculate !== void 0) {
|
|
@@ -5314,6 +5352,8 @@ function runOrScheduleMVCPRecalculate(ctx) {
|
|
|
5314
5352
|
function updateItemSize(ctx, itemKey, sizeObj) {
|
|
5315
5353
|
var _a3;
|
|
5316
5354
|
const state = ctx.state;
|
|
5355
|
+
const userScrollAnchorResetKeys = state.userScrollAnchorResetKeys;
|
|
5356
|
+
const didMeasureUserScrollAnchorResetItem = !!(userScrollAnchorResetKeys == null ? void 0 : userScrollAnchorResetKeys.delete(itemKey));
|
|
5317
5357
|
const {
|
|
5318
5358
|
didContainersLayout,
|
|
5319
5359
|
sizesKnown,
|
|
@@ -5392,10 +5432,12 @@ function updateItemSize(ctx, itemKey, sizeObj) {
|
|
|
5392
5432
|
if (!cur || maxOtherAxisSize > cur) {
|
|
5393
5433
|
set$(ctx, "otherAxisSize", maxOtherAxisSize);
|
|
5394
5434
|
}
|
|
5395
|
-
if (didContainersLayout || checkAllSizesKnown(state)) {
|
|
5435
|
+
if (didContainersLayout || checkAllSizesKnown(state, getMountedBufferedIndices(state))) {
|
|
5396
5436
|
if (needsRecalculate) {
|
|
5397
5437
|
state.scrollForNextCalculateItemsInView = void 0;
|
|
5398
5438
|
runOrScheduleMVCPRecalculate(ctx);
|
|
5439
|
+
} else if (didMeasureUserScrollAnchorResetItem && (userScrollAnchorResetKeys == null ? void 0 : userScrollAnchorResetKeys.size) === 0) {
|
|
5440
|
+
state.userScrollAnchorResetKeys = void 0;
|
|
5399
5441
|
}
|
|
5400
5442
|
if (shouldMaintainScrollAtEnd) {
|
|
5401
5443
|
if (maintainScrollAtEnd == null ? void 0 : maintainScrollAtEnd.onItemLayout) {
|
package/react.js
CHANGED
|
@@ -2083,7 +2083,7 @@ function getId(state, index) {
|
|
|
2083
2083
|
}
|
|
2084
2084
|
|
|
2085
2085
|
// src/core/addTotalSize.ts
|
|
2086
|
-
function addTotalSize(ctx, key, add) {
|
|
2086
|
+
function addTotalSize(ctx, key, add, notifyTotalSize = true) {
|
|
2087
2087
|
const state = ctx.state;
|
|
2088
2088
|
const prevTotalSize = state.totalSize;
|
|
2089
2089
|
let totalSize = state.totalSize;
|
|
@@ -2100,25 +2100,29 @@ function addTotalSize(ctx, key, add) {
|
|
|
2100
2100
|
{
|
|
2101
2101
|
state.pendingTotalSize = void 0;
|
|
2102
2102
|
state.totalSize = totalSize;
|
|
2103
|
-
|
|
2103
|
+
if (notifyTotalSize) {
|
|
2104
|
+
set$(ctx, "totalSize", totalSize);
|
|
2105
|
+
}
|
|
2104
2106
|
}
|
|
2107
|
+
} else if (notifyTotalSize && ctx.values.get("totalSize") !== totalSize) {
|
|
2108
|
+
set$(ctx, "totalSize", totalSize);
|
|
2105
2109
|
}
|
|
2106
2110
|
}
|
|
2107
2111
|
|
|
2108
2112
|
// src/core/setSize.ts
|
|
2109
|
-
function setSize(ctx, itemKey, size) {
|
|
2113
|
+
function setSize(ctx, itemKey, size, notifyTotalSize = true) {
|
|
2110
2114
|
const state = ctx.state;
|
|
2111
2115
|
const { sizes } = state;
|
|
2112
2116
|
const previousSize = sizes.get(itemKey);
|
|
2113
2117
|
const diff = previousSize !== void 0 ? size - previousSize : size;
|
|
2114
2118
|
if (diff !== 0) {
|
|
2115
|
-
addTotalSize(ctx, itemKey, diff);
|
|
2119
|
+
addTotalSize(ctx, itemKey, diff, notifyTotalSize);
|
|
2116
2120
|
}
|
|
2117
2121
|
sizes.set(itemKey, size);
|
|
2118
2122
|
}
|
|
2119
2123
|
|
|
2120
2124
|
// src/utils/getItemSize.ts
|
|
2121
|
-
function getItemSize(ctx, key, index, data, useAverageSize, preferCachedSize) {
|
|
2125
|
+
function getItemSize(ctx, key, index, data, useAverageSize, preferCachedSize, notifyTotalSize) {
|
|
2122
2126
|
var _a3, _b, _c;
|
|
2123
2127
|
const state = ctx.state;
|
|
2124
2128
|
const {
|
|
@@ -2164,7 +2168,7 @@ function getItemSize(ctx, key, index, data, useAverageSize, preferCachedSize) {
|
|
|
2164
2168
|
if (size === void 0) {
|
|
2165
2169
|
size = getEstimatedItemSize ? getEstimatedItemSize(data, index, itemType) : estimatedItemSize;
|
|
2166
2170
|
}
|
|
2167
|
-
setSize(ctx, key, size);
|
|
2171
|
+
setSize(ctx, key, size, notifyTotalSize);
|
|
2168
2172
|
return size;
|
|
2169
2173
|
}
|
|
2170
2174
|
function getItemSizeAtIndex(ctx, index) {
|
|
@@ -2603,10 +2607,10 @@ function getMountedBufferedIndices(state) {
|
|
|
2603
2607
|
function getMountedNoBufferIndices(state) {
|
|
2604
2608
|
return getMountedIndicesInRange(state, state.startNoBuffer, state.endNoBuffer);
|
|
2605
2609
|
}
|
|
2606
|
-
function checkAllSizesKnown(state, indices
|
|
2610
|
+
function checkAllSizesKnown(state, indices) {
|
|
2607
2611
|
return indices.length > 0 && indices.every((index) => {
|
|
2608
2612
|
const key = getId(state, index);
|
|
2609
|
-
return state.sizesKnown.has(key);
|
|
2613
|
+
return key !== void 0 && state.sizesKnown.has(key);
|
|
2610
2614
|
});
|
|
2611
2615
|
}
|
|
2612
2616
|
|
|
@@ -3916,6 +3920,7 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
|
|
|
3916
3920
|
const maxVisibleArea = scrollBottomBuffered + 1e3;
|
|
3917
3921
|
const useAverageSize = !getEstimatedItemSize;
|
|
3918
3922
|
const preferCachedSize = !doMVCP || dataChanged || state.scrollAdjustHandler.getAdjust() !== 0 || ((_b = peek$(ctx, "scrollAdjustPending")) != null ? _b : 0) !== 0;
|
|
3923
|
+
const notifyTotalSizeWhileCachingSizes = false;
|
|
3919
3924
|
let currentRowTop = 0;
|
|
3920
3925
|
let column = 1;
|
|
3921
3926
|
let maxSizeInRow = 0;
|
|
@@ -3943,7 +3948,15 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
|
|
|
3943
3948
|
const prevIndex = startIndex - 1;
|
|
3944
3949
|
const prevId = getId(state, prevIndex);
|
|
3945
3950
|
const prevPosition = (_c = positions[prevIndex]) != null ? _c : 0;
|
|
3946
|
-
const prevSize = (_d = sizesKnown.get(prevId)) != null ? _d : getItemSize(
|
|
3951
|
+
const prevSize = (_d = sizesKnown.get(prevId)) != null ? _d : getItemSize(
|
|
3952
|
+
ctx,
|
|
3953
|
+
prevId,
|
|
3954
|
+
prevIndex,
|
|
3955
|
+
data[prevIndex],
|
|
3956
|
+
useAverageSize,
|
|
3957
|
+
preferCachedSize,
|
|
3958
|
+
notifyTotalSizeWhileCachingSizes
|
|
3959
|
+
);
|
|
3947
3960
|
currentRowTop = prevPosition + prevSize;
|
|
3948
3961
|
}
|
|
3949
3962
|
}
|
|
@@ -3976,7 +3989,7 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
|
|
|
3976
3989
|
maxSizeInRow = 0;
|
|
3977
3990
|
}
|
|
3978
3991
|
const knownSize = sizesKnown.get(id);
|
|
3979
|
-
const size = knownSize !== void 0 ? knownSize : getItemSize(ctx, id, i, data[i], useAverageSize, preferCachedSize);
|
|
3992
|
+
const size = knownSize !== void 0 ? knownSize : getItemSize(ctx, id, i, data[i], useAverageSize, preferCachedSize, notifyTotalSizeWhileCachingSizes);
|
|
3980
3993
|
if (IS_DEV && needsIndexByKey) {
|
|
3981
3994
|
if (indexByKeyForChecking.has(id)) {
|
|
3982
3995
|
console.error(
|
|
@@ -4451,7 +4464,7 @@ function handleStickyRecycling(ctx, stickyArray, scroll, drawDistance, currentSt
|
|
|
4451
4464
|
function calculateItemsInView(ctx, params = {}) {
|
|
4452
4465
|
const state = ctx.state;
|
|
4453
4466
|
batchedUpdates(() => {
|
|
4454
|
-
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
4467
|
+
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
4455
4468
|
const {
|
|
4456
4469
|
columns,
|
|
4457
4470
|
columnSpans,
|
|
@@ -4740,6 +4753,7 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4740
4753
|
state.containerItemTypes.set(containerIndex, requiredItemTypes[idx]);
|
|
4741
4754
|
}
|
|
4742
4755
|
containerItemKeys.set(id, containerIndex);
|
|
4756
|
+
(_p = state.userScrollAnchorResetKeys) == null ? void 0 : _p.add(id);
|
|
4743
4757
|
const containerSticky = `containerSticky${containerIndex}`;
|
|
4744
4758
|
const isSticky = stickyIndicesSet.has(i);
|
|
4745
4759
|
const isAlwaysRender = alwaysRenderSet.has(i);
|
|
@@ -4767,10 +4781,13 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4767
4781
|
}
|
|
4768
4782
|
}
|
|
4769
4783
|
}
|
|
4784
|
+
if (((_q = state.userScrollAnchorResetKeys) == null ? void 0 : _q.size) === 0) {
|
|
4785
|
+
state.userScrollAnchorResetKeys = void 0;
|
|
4786
|
+
}
|
|
4770
4787
|
if (alwaysRenderArr.length > 0) {
|
|
4771
4788
|
for (const index of alwaysRenderArr) {
|
|
4772
4789
|
if (index < 0 || index >= dataLength) continue;
|
|
4773
|
-
const id = (
|
|
4790
|
+
const id = (_r = idCache[index]) != null ? _r : getId(state, index);
|
|
4774
4791
|
const containerIndex = containerItemKeys.get(id);
|
|
4775
4792
|
if (containerIndex !== void 0) {
|
|
4776
4793
|
state.stickyContainerPool.add(containerIndex);
|
|
@@ -5131,7 +5148,14 @@ function updateScroll(ctx, newScroll, forceUpdate) {
|
|
|
5131
5148
|
(_a4 = state.triggerCalculateItemsInView) == null ? void 0 : _a4.call(state, { doMVCP: scrollingTo !== void 0 });
|
|
5132
5149
|
checkThresholds(ctx);
|
|
5133
5150
|
};
|
|
5134
|
-
if (scrollLength > 0 && scrollingTo === void 0 && scrollDelta > scrollLength) {
|
|
5151
|
+
if (scrollLength > 0 && scrollingTo === void 0 && scrollDelta > scrollLength && !state.pendingNativeMVCPAdjust) {
|
|
5152
|
+
state.mvcpAnchorLock = void 0;
|
|
5153
|
+
state.pendingNativeMVCPAdjust = void 0;
|
|
5154
|
+
state.userScrollAnchorResetKeys = /* @__PURE__ */ new Set();
|
|
5155
|
+
if (state.queuedMVCPRecalculate !== void 0) {
|
|
5156
|
+
cancelAnimationFrame(state.queuedMVCPRecalculate);
|
|
5157
|
+
state.queuedMVCPRecalculate = void 0;
|
|
5158
|
+
}
|
|
5135
5159
|
ReactDOM.flushSync(runCalculateItems);
|
|
5136
5160
|
} else {
|
|
5137
5161
|
runCalculateItems();
|
|
@@ -5314,6 +5338,20 @@ function maybeUpdateAnchoredEndSpace(ctx) {
|
|
|
5314
5338
|
// src/core/updateItemSize.ts
|
|
5315
5339
|
function runOrScheduleMVCPRecalculate(ctx) {
|
|
5316
5340
|
const state = ctx.state;
|
|
5341
|
+
if (state.userScrollAnchorResetKeys !== void 0) {
|
|
5342
|
+
if (state.queuedMVCPRecalculate !== void 0) {
|
|
5343
|
+
return;
|
|
5344
|
+
}
|
|
5345
|
+
state.queuedMVCPRecalculate = requestAnimationFrame(() => {
|
|
5346
|
+
var _a3;
|
|
5347
|
+
state.queuedMVCPRecalculate = void 0;
|
|
5348
|
+
calculateItemsInView(ctx);
|
|
5349
|
+
if (((_a3 = state.userScrollAnchorResetKeys) == null ? void 0 : _a3.size) === 0) {
|
|
5350
|
+
state.userScrollAnchorResetKeys = void 0;
|
|
5351
|
+
}
|
|
5352
|
+
});
|
|
5353
|
+
return;
|
|
5354
|
+
}
|
|
5317
5355
|
{
|
|
5318
5356
|
if (!state.mvcpAnchorLock) {
|
|
5319
5357
|
if (state.queuedMVCPRecalculate !== void 0) {
|
|
@@ -5335,6 +5373,8 @@ function runOrScheduleMVCPRecalculate(ctx) {
|
|
|
5335
5373
|
function updateItemSize(ctx, itemKey, sizeObj) {
|
|
5336
5374
|
var _a3;
|
|
5337
5375
|
const state = ctx.state;
|
|
5376
|
+
const userScrollAnchorResetKeys = state.userScrollAnchorResetKeys;
|
|
5377
|
+
const didMeasureUserScrollAnchorResetItem = !!(userScrollAnchorResetKeys == null ? void 0 : userScrollAnchorResetKeys.delete(itemKey));
|
|
5338
5378
|
const {
|
|
5339
5379
|
didContainersLayout,
|
|
5340
5380
|
sizesKnown,
|
|
@@ -5413,10 +5453,12 @@ function updateItemSize(ctx, itemKey, sizeObj) {
|
|
|
5413
5453
|
if (!cur || maxOtherAxisSize > cur) {
|
|
5414
5454
|
set$(ctx, "otherAxisSize", maxOtherAxisSize);
|
|
5415
5455
|
}
|
|
5416
|
-
if (didContainersLayout || checkAllSizesKnown(state)) {
|
|
5456
|
+
if (didContainersLayout || checkAllSizesKnown(state, getMountedBufferedIndices(state))) {
|
|
5417
5457
|
if (needsRecalculate) {
|
|
5418
5458
|
state.scrollForNextCalculateItemsInView = void 0;
|
|
5419
5459
|
runOrScheduleMVCPRecalculate(ctx);
|
|
5460
|
+
} else if (didMeasureUserScrollAnchorResetItem && (userScrollAnchorResetKeys == null ? void 0 : userScrollAnchorResetKeys.size) === 0) {
|
|
5461
|
+
state.userScrollAnchorResetKeys = void 0;
|
|
5420
5462
|
}
|
|
5421
5463
|
if (shouldMaintainScrollAtEnd) {
|
|
5422
5464
|
if (maintainScrollAtEnd == null ? void 0 : maintainScrollAtEnd.onItemLayout) {
|