@legendapp/list 3.0.0-beta.47 → 3.0.0-beta.48
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.js +42 -24
- package/index.mjs +42 -24
- package/index.native.js +73 -52
- package/index.native.mjs +73 -52
- package/package.json +1 -1
- package/react-native.js +73 -52
- package/react-native.mjs +73 -52
- package/react-native.web.js +42 -24
- package/react-native.web.mjs +42 -24
- package/react.js +42 -24
- package/react.mjs +42 -24
package/react-native.mjs
CHANGED
|
@@ -834,6 +834,35 @@ var Container = typedMemo(function Container2({
|
|
|
834
834
|
});
|
|
835
835
|
|
|
836
836
|
// src/components/Containers.native.tsx
|
|
837
|
+
var ContainersLayer = typedMemo(function ContainersLayer2({ children, horizontal }) {
|
|
838
|
+
const ctx = useStateContext();
|
|
839
|
+
const columnWrapperStyle = ctx.columnWrapperStyle;
|
|
840
|
+
const animSize = useValue$("totalSize");
|
|
841
|
+
const otherAxisSize = useValue$("otherAxisSize");
|
|
842
|
+
const [readyToRender, numColumns] = useArr$(["readyToRender", "numColumns"]);
|
|
843
|
+
const style = horizontal ? { minHeight: otherAxisSize, opacity: readyToRender ? 1 : 0, width: animSize } : { height: animSize, minWidth: otherAxisSize, opacity: readyToRender ? 1 : 0 };
|
|
844
|
+
if (columnWrapperStyle) {
|
|
845
|
+
const { columnGap, rowGap, gap } = columnWrapperStyle;
|
|
846
|
+
const gapX = columnGap || gap || 0;
|
|
847
|
+
const gapY = rowGap || gap || 0;
|
|
848
|
+
if (horizontal) {
|
|
849
|
+
if (gapY && numColumns > 1) {
|
|
850
|
+
style.marginVertical = -gapY / 2;
|
|
851
|
+
}
|
|
852
|
+
if (gapX) {
|
|
853
|
+
style.marginRight = -gapX;
|
|
854
|
+
}
|
|
855
|
+
} else {
|
|
856
|
+
if (gapX && numColumns > 1) {
|
|
857
|
+
style.marginHorizontal = -gapX;
|
|
858
|
+
}
|
|
859
|
+
if (gapY) {
|
|
860
|
+
style.marginBottom = -gapY;
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
return /* @__PURE__ */ React2.createElement(Animated.View, { style }, children);
|
|
865
|
+
});
|
|
837
866
|
var Containers = typedMemo(function Containers2({
|
|
838
867
|
horizontal,
|
|
839
868
|
recycleItems,
|
|
@@ -842,12 +871,7 @@ var Containers = typedMemo(function Containers2({
|
|
|
842
871
|
updateItemSize: updateItemSize2,
|
|
843
872
|
getRenderedItem: getRenderedItem2
|
|
844
873
|
}) {
|
|
845
|
-
const
|
|
846
|
-
const columnWrapperStyle = ctx.columnWrapperStyle;
|
|
847
|
-
const [numContainers, numColumns] = useArr$(["numContainersPooled", "numColumns"]);
|
|
848
|
-
const animSize = useValue$("totalSize");
|
|
849
|
-
const otherAxisSize = useValue$("otherAxisSize");
|
|
850
|
-
const animOpacity = useValue$("readyToRender", { getValue: (value) => value ? 1 : 0 });
|
|
874
|
+
const [numContainers] = useArr$(["numContainersPooled"]);
|
|
851
875
|
const containers = [];
|
|
852
876
|
for (let i = 0; i < numContainers; i++) {
|
|
853
877
|
containers.push(
|
|
@@ -866,28 +890,7 @@ var Containers = typedMemo(function Containers2({
|
|
|
866
890
|
)
|
|
867
891
|
);
|
|
868
892
|
}
|
|
869
|
-
|
|
870
|
-
if (columnWrapperStyle) {
|
|
871
|
-
const { columnGap, rowGap, gap } = columnWrapperStyle;
|
|
872
|
-
const gapX = columnGap || gap || 0;
|
|
873
|
-
const gapY = rowGap || gap || 0;
|
|
874
|
-
if (horizontal) {
|
|
875
|
-
if (gapY && numColumns > 1) {
|
|
876
|
-
style.marginVertical = -gapY / 2;
|
|
877
|
-
}
|
|
878
|
-
if (gapX) {
|
|
879
|
-
style.marginRight = -gapX;
|
|
880
|
-
}
|
|
881
|
-
} else {
|
|
882
|
-
if (gapX && numColumns > 1) {
|
|
883
|
-
style.marginHorizontal = -gapX;
|
|
884
|
-
}
|
|
885
|
-
if (gapY) {
|
|
886
|
-
style.marginBottom = -gapY;
|
|
887
|
-
}
|
|
888
|
-
}
|
|
889
|
-
}
|
|
890
|
-
return /* @__PURE__ */ React2.createElement(Animated.View, { style }, containers);
|
|
893
|
+
return /* @__PURE__ */ React2.createElement(ContainersLayer, { horizontal }, containers);
|
|
891
894
|
});
|
|
892
895
|
var ListComponentScrollView = Animated.ScrollView;
|
|
893
896
|
function ScrollAdjust() {
|
|
@@ -3677,7 +3680,7 @@ function computeViewability(state, ctx, viewabilityConfig, containerId, key, scr
|
|
|
3677
3680
|
}
|
|
3678
3681
|
function checkIsViewable(state, ctx, viewabilityConfig, containerId, key, scrollSize, item, index) {
|
|
3679
3682
|
let value = ctx.mapViewabilityAmountValues.get(containerId);
|
|
3680
|
-
if (!value || value.key !== key) {
|
|
3683
|
+
if (!value || value.key !== key || value.index !== index) {
|
|
3681
3684
|
value = computeViewability(state, ctx, viewabilityConfig, containerId, key, scrollSize, item, index);
|
|
3682
3685
|
}
|
|
3683
3686
|
return value.isViewable;
|
|
@@ -3692,7 +3695,7 @@ var unstableBatchedUpdates = ReactNative.unstable_batchedUpdates;
|
|
|
3692
3695
|
var batchedUpdates = typeof unstableBatchedUpdates === "function" ? unstableBatchedUpdates : (fn) => fn();
|
|
3693
3696
|
|
|
3694
3697
|
// src/utils/findAvailableContainers.ts
|
|
3695
|
-
function findAvailableContainers(ctx, numNeeded, startBuffered, endBuffered, pendingRemoval, requiredItemTypes, needNewContainers) {
|
|
3698
|
+
function findAvailableContainers(ctx, numNeeded, startBuffered, endBuffered, pendingRemoval, requiredItemTypes, needNewContainers, protectedKeys) {
|
|
3696
3699
|
const numContainers = peek$(ctx, "numContainers");
|
|
3697
3700
|
const state = ctx.state;
|
|
3698
3701
|
const { stickyContainerPool, containerItemTypes } = state;
|
|
@@ -3760,6 +3763,7 @@ function findAvailableContainers(ctx, numNeeded, startBuffered, endBuffered, pen
|
|
|
3760
3763
|
}
|
|
3761
3764
|
const key = peek$(ctx, `containerItemKey${u}`);
|
|
3762
3765
|
if (key === void 0) continue;
|
|
3766
|
+
if ((protectedKeys == null ? void 0 : protectedKeys.has(key)) && state.indexByKey.has(key)) continue;
|
|
3763
3767
|
const index = state.indexByKey.get(key);
|
|
3764
3768
|
const isOutOfView = index < startBuffered || index > endBuffered;
|
|
3765
3769
|
if (isOutOfView) {
|
|
@@ -3895,7 +3899,7 @@ function handleStickyRecycling(ctx, stickyArray, scroll, drawDistance, currentSt
|
|
|
3895
3899
|
function calculateItemsInView(ctx, params = {}) {
|
|
3896
3900
|
const state = ctx.state;
|
|
3897
3901
|
batchedUpdates(() => {
|
|
3898
|
-
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
3902
|
+
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
3899
3903
|
const {
|
|
3900
3904
|
columns,
|
|
3901
3905
|
columnSpans,
|
|
@@ -3997,17 +4001,31 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
3997
4001
|
if (minIndexSizeChanged !== void 0) {
|
|
3998
4002
|
state.minIndexSizeChanged = void 0;
|
|
3999
4003
|
}
|
|
4004
|
+
let protectedContainerKeys;
|
|
4005
|
+
if (dataChanged && doMVCP && state.props.maintainVisibleContentPosition.data && state.didContainersLayout && state.idsInView.length > 0) {
|
|
4006
|
+
const shouldRestorePosition = state.props.maintainVisibleContentPosition.shouldRestorePosition;
|
|
4007
|
+
protectedContainerKeys = /* @__PURE__ */ new Set();
|
|
4008
|
+
for (const id of state.idsInView) {
|
|
4009
|
+
const index = indexByKey.get(id);
|
|
4010
|
+
if (index === void 0) continue;
|
|
4011
|
+
if (shouldRestorePosition && !shouldRestorePosition(data[index], index, data)) continue;
|
|
4012
|
+
protectedContainerKeys.add(id);
|
|
4013
|
+
}
|
|
4014
|
+
}
|
|
4015
|
+
const scrollBeforeMVCP = state.scroll;
|
|
4016
|
+
const scrollAdjustPendingBeforeMVCP = (_e = peek$(ctx, "scrollAdjustPending")) != null ? _e : 0;
|
|
4000
4017
|
checkMVCP == null ? void 0 : checkMVCP();
|
|
4018
|
+
const didMVCPAdjustScroll = !!checkMVCP && (state.scroll !== scrollBeforeMVCP || ((_f = peek$(ctx, "scrollAdjustPending")) != null ? _f : 0) !== scrollAdjustPendingBeforeMVCP);
|
|
4001
4019
|
let startNoBuffer = null;
|
|
4002
4020
|
let startBuffered = null;
|
|
4003
4021
|
let startBufferedId = null;
|
|
4004
4022
|
let endNoBuffer = null;
|
|
4005
4023
|
let endBuffered = null;
|
|
4006
|
-
let loopStart = (
|
|
4024
|
+
let loopStart = (_g = suppressInitialScrollSideEffects ? bootstrapInitialScrollState == null ? void 0 : bootstrapInitialScrollState.targetIndexSeed : void 0) != null ? _g : !dataChanged && startBufferedIdOrig ? indexByKey.get(startBufferedIdOrig) || 0 : 0;
|
|
4007
4025
|
for (let i = loopStart; i >= 0; i--) {
|
|
4008
|
-
const id = (
|
|
4026
|
+
const id = (_h = idCache[i]) != null ? _h : getId(state, i);
|
|
4009
4027
|
const top = positions[i];
|
|
4010
|
-
const size = (
|
|
4028
|
+
const size = (_i = sizes.get(id)) != null ? _i : getItemSize(ctx, id, i, data[i]);
|
|
4011
4029
|
const bottom = top + size;
|
|
4012
4030
|
if (bottom > scroll - scrollBufferTop) {
|
|
4013
4031
|
loopStart = i;
|
|
@@ -4038,8 +4056,8 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4038
4056
|
let firstFullyOnScreenIndex;
|
|
4039
4057
|
const dataLength = data.length;
|
|
4040
4058
|
for (let i = Math.max(0, loopStart); i < dataLength && (!foundEnd || i <= maxIndexRendered); i++) {
|
|
4041
|
-
const id = (
|
|
4042
|
-
const size = (
|
|
4059
|
+
const id = (_j = idCache[i]) != null ? _j : getId(state, i);
|
|
4060
|
+
const size = (_k = sizes.get(id)) != null ? _k : getItemSize(ctx, id, i, data[i]);
|
|
4043
4061
|
const top = positions[i];
|
|
4044
4062
|
if (!foundEnd) {
|
|
4045
4063
|
if (startNoBuffer === null && top + size > scroll) {
|
|
@@ -4078,7 +4096,7 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4078
4096
|
const firstVisibleAnchorIndex = firstFullyOnScreenIndex != null ? firstFullyOnScreenIndex : startNoBuffer;
|
|
4079
4097
|
if (firstVisibleAnchorIndex !== null && firstVisibleAnchorIndex !== void 0 && endNoBuffer !== null) {
|
|
4080
4098
|
for (let i = firstVisibleAnchorIndex; i <= endNoBuffer; i++) {
|
|
4081
|
-
const id = (
|
|
4099
|
+
const id = (_l = idCache[i]) != null ? _l : getId(state, i);
|
|
4082
4100
|
idsInView.push(id);
|
|
4083
4101
|
}
|
|
4084
4102
|
}
|
|
@@ -4111,7 +4129,7 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4111
4129
|
const needNewContainers = [];
|
|
4112
4130
|
const needNewContainersSet = /* @__PURE__ */ new Set();
|
|
4113
4131
|
for (let i = startBuffered; i <= endBuffered; i++) {
|
|
4114
|
-
const id = (
|
|
4132
|
+
const id = (_m = idCache[i]) != null ? _m : getId(state, i);
|
|
4115
4133
|
if (!containerItemKeys.has(id)) {
|
|
4116
4134
|
needNewContainersSet.add(i);
|
|
4117
4135
|
needNewContainers.push(i);
|
|
@@ -4120,7 +4138,7 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4120
4138
|
if (alwaysRenderArr.length > 0) {
|
|
4121
4139
|
for (const index of alwaysRenderArr) {
|
|
4122
4140
|
if (index < 0 || index >= dataLength) continue;
|
|
4123
|
-
const id = (
|
|
4141
|
+
const id = (_n = idCache[index]) != null ? _n : getId(state, index);
|
|
4124
4142
|
if (id && !containerItemKeys.has(id) && !needNewContainersSet.has(index)) {
|
|
4125
4143
|
needNewContainersSet.add(index);
|
|
4126
4144
|
needNewContainers.push(index);
|
|
@@ -4153,12 +4171,13 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4153
4171
|
endBuffered,
|
|
4154
4172
|
pendingRemoval,
|
|
4155
4173
|
requiredItemTypes,
|
|
4156
|
-
needNewContainers
|
|
4174
|
+
needNewContainers,
|
|
4175
|
+
protectedContainerKeys
|
|
4157
4176
|
);
|
|
4158
4177
|
for (let idx = 0; idx < needNewContainers.length; idx++) {
|
|
4159
4178
|
const i = needNewContainers[idx];
|
|
4160
4179
|
const containerIndex = availableContainers[idx];
|
|
4161
|
-
const id = (
|
|
4180
|
+
const id = (_o = idCache[i]) != null ? _o : getId(state, i);
|
|
4162
4181
|
const oldKey = peek$(ctx, `containerItemKey${containerIndex}`);
|
|
4163
4182
|
if (oldKey && oldKey !== id) {
|
|
4164
4183
|
containerItemKeys.delete(oldKey);
|
|
@@ -4199,7 +4218,7 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4199
4218
|
if (alwaysRenderArr.length > 0) {
|
|
4200
4219
|
for (const index of alwaysRenderArr) {
|
|
4201
4220
|
if (index < 0 || index >= dataLength) continue;
|
|
4202
|
-
const id = (
|
|
4221
|
+
const id = (_p = idCache[index]) != null ? _p : getId(state, index);
|
|
4203
4222
|
const containerIndex = containerItemKeys.get(id);
|
|
4204
4223
|
if (containerIndex !== void 0) {
|
|
4205
4224
|
state.stickyContainerPool.add(containerIndex);
|
|
@@ -4260,16 +4279,18 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4260
4279
|
handleInitialScrollLayoutReady(ctx);
|
|
4261
4280
|
}
|
|
4262
4281
|
if (viewabilityConfigCallbackPairs && startNoBuffer !== null && endNoBuffer !== null) {
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4282
|
+
if (!didMVCPAdjustScroll) {
|
|
4283
|
+
updateViewableItems(
|
|
4284
|
+
ctx.state,
|
|
4285
|
+
ctx,
|
|
4286
|
+
viewabilityConfigCallbackPairs,
|
|
4287
|
+
scrollLength,
|
|
4288
|
+
startNoBuffer,
|
|
4289
|
+
endNoBuffer,
|
|
4290
|
+
startBuffered != null ? startBuffered : startNoBuffer,
|
|
4291
|
+
endBuffered != null ? endBuffered : endNoBuffer
|
|
4292
|
+
);
|
|
4293
|
+
}
|
|
4273
4294
|
}
|
|
4274
4295
|
if (onStickyHeaderChange && stickyIndicesArr.length > 0 && nextActiveStickyIndex !== void 0 && nextActiveStickyIndex !== previousStickyIndex) {
|
|
4275
4296
|
const item = data[nextActiveStickyIndex];
|
package/react-native.web.js
CHANGED
|
@@ -4232,7 +4232,7 @@ function computeViewability(state, ctx, viewabilityConfig, containerId, key, scr
|
|
|
4232
4232
|
}
|
|
4233
4233
|
function checkIsViewable(state, ctx, viewabilityConfig, containerId, key, scrollSize, item, index) {
|
|
4234
4234
|
let value = ctx.mapViewabilityAmountValues.get(containerId);
|
|
4235
|
-
if (!value || value.key !== key) {
|
|
4235
|
+
if (!value || value.key !== key || value.index !== index) {
|
|
4236
4236
|
value = computeViewability(state, ctx, viewabilityConfig, containerId, key, scrollSize, item, index);
|
|
4237
4237
|
}
|
|
4238
4238
|
return value.isViewable;
|
|
@@ -4247,7 +4247,7 @@ var unstableBatchedUpdates = ReactDOM__namespace.unstable_batchedUpdates;
|
|
|
4247
4247
|
var batchedUpdates = typeof unstableBatchedUpdates === "function" ? unstableBatchedUpdates : (fn) => fn();
|
|
4248
4248
|
|
|
4249
4249
|
// src/utils/findAvailableContainers.ts
|
|
4250
|
-
function findAvailableContainers(ctx, numNeeded, startBuffered, endBuffered, pendingRemoval, requiredItemTypes, needNewContainers) {
|
|
4250
|
+
function findAvailableContainers(ctx, numNeeded, startBuffered, endBuffered, pendingRemoval, requiredItemTypes, needNewContainers, protectedKeys) {
|
|
4251
4251
|
const numContainers = peek$(ctx, "numContainers");
|
|
4252
4252
|
const state = ctx.state;
|
|
4253
4253
|
const { stickyContainerPool, containerItemTypes } = state;
|
|
@@ -4315,6 +4315,7 @@ function findAvailableContainers(ctx, numNeeded, startBuffered, endBuffered, pen
|
|
|
4315
4315
|
}
|
|
4316
4316
|
const key = peek$(ctx, `containerItemKey${u}`);
|
|
4317
4317
|
if (key === void 0) continue;
|
|
4318
|
+
if ((protectedKeys == null ? void 0 : protectedKeys.has(key)) && state.indexByKey.has(key)) continue;
|
|
4318
4319
|
const index = state.indexByKey.get(key);
|
|
4319
4320
|
const isOutOfView = index < startBuffered || index > endBuffered;
|
|
4320
4321
|
if (isOutOfView) {
|
|
@@ -4450,7 +4451,7 @@ function handleStickyRecycling(ctx, stickyArray, scroll, drawDistance, currentSt
|
|
|
4450
4451
|
function calculateItemsInView(ctx, params = {}) {
|
|
4451
4452
|
const state = ctx.state;
|
|
4452
4453
|
batchedUpdates(() => {
|
|
4453
|
-
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
4454
|
+
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
4454
4455
|
const {
|
|
4455
4456
|
columns,
|
|
4456
4457
|
columnSpans,
|
|
@@ -4552,17 +4553,31 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4552
4553
|
if (minIndexSizeChanged !== void 0) {
|
|
4553
4554
|
state.minIndexSizeChanged = void 0;
|
|
4554
4555
|
}
|
|
4556
|
+
let protectedContainerKeys;
|
|
4557
|
+
if (dataChanged && doMVCP && state.props.maintainVisibleContentPosition.data && state.didContainersLayout && state.idsInView.length > 0) {
|
|
4558
|
+
const shouldRestorePosition = state.props.maintainVisibleContentPosition.shouldRestorePosition;
|
|
4559
|
+
protectedContainerKeys = /* @__PURE__ */ new Set();
|
|
4560
|
+
for (const id of state.idsInView) {
|
|
4561
|
+
const index = indexByKey.get(id);
|
|
4562
|
+
if (index === void 0) continue;
|
|
4563
|
+
if (shouldRestorePosition && !shouldRestorePosition(data[index], index, data)) continue;
|
|
4564
|
+
protectedContainerKeys.add(id);
|
|
4565
|
+
}
|
|
4566
|
+
}
|
|
4567
|
+
const scrollBeforeMVCP = state.scroll;
|
|
4568
|
+
const scrollAdjustPendingBeforeMVCP = (_e = peek$(ctx, "scrollAdjustPending")) != null ? _e : 0;
|
|
4555
4569
|
checkMVCP == null ? void 0 : checkMVCP();
|
|
4570
|
+
const didMVCPAdjustScroll = !!checkMVCP && (state.scroll !== scrollBeforeMVCP || ((_f = peek$(ctx, "scrollAdjustPending")) != null ? _f : 0) !== scrollAdjustPendingBeforeMVCP);
|
|
4556
4571
|
let startNoBuffer = null;
|
|
4557
4572
|
let startBuffered = null;
|
|
4558
4573
|
let startBufferedId = null;
|
|
4559
4574
|
let endNoBuffer = null;
|
|
4560
4575
|
let endBuffered = null;
|
|
4561
|
-
let loopStart = (
|
|
4576
|
+
let loopStart = (_g = suppressInitialScrollSideEffects ? bootstrapInitialScrollState == null ? void 0 : bootstrapInitialScrollState.targetIndexSeed : void 0) != null ? _g : !dataChanged && startBufferedIdOrig ? indexByKey.get(startBufferedIdOrig) || 0 : 0;
|
|
4562
4577
|
for (let i = loopStart; i >= 0; i--) {
|
|
4563
|
-
const id = (
|
|
4578
|
+
const id = (_h = idCache[i]) != null ? _h : getId(state, i);
|
|
4564
4579
|
const top = positions[i];
|
|
4565
|
-
const size = (
|
|
4580
|
+
const size = (_i = sizes.get(id)) != null ? _i : getItemSize(ctx, id, i, data[i]);
|
|
4566
4581
|
const bottom = top + size;
|
|
4567
4582
|
if (bottom > scroll - scrollBufferTop) {
|
|
4568
4583
|
loopStart = i;
|
|
@@ -4593,8 +4608,8 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4593
4608
|
let firstFullyOnScreenIndex;
|
|
4594
4609
|
const dataLength = data.length;
|
|
4595
4610
|
for (let i = Math.max(0, loopStart); i < dataLength && (!foundEnd || i <= maxIndexRendered); i++) {
|
|
4596
|
-
const id = (
|
|
4597
|
-
const size = (
|
|
4611
|
+
const id = (_j = idCache[i]) != null ? _j : getId(state, i);
|
|
4612
|
+
const size = (_k = sizes.get(id)) != null ? _k : getItemSize(ctx, id, i, data[i]);
|
|
4598
4613
|
const top = positions[i];
|
|
4599
4614
|
if (!foundEnd) {
|
|
4600
4615
|
if (startNoBuffer === null && top + size > scroll) {
|
|
@@ -4633,7 +4648,7 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4633
4648
|
const firstVisibleAnchorIndex = firstFullyOnScreenIndex != null ? firstFullyOnScreenIndex : startNoBuffer;
|
|
4634
4649
|
if (firstVisibleAnchorIndex !== null && firstVisibleAnchorIndex !== void 0 && endNoBuffer !== null) {
|
|
4635
4650
|
for (let i = firstVisibleAnchorIndex; i <= endNoBuffer; i++) {
|
|
4636
|
-
const id = (
|
|
4651
|
+
const id = (_l = idCache[i]) != null ? _l : getId(state, i);
|
|
4637
4652
|
idsInView.push(id);
|
|
4638
4653
|
}
|
|
4639
4654
|
}
|
|
@@ -4666,7 +4681,7 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4666
4681
|
const needNewContainers = [];
|
|
4667
4682
|
const needNewContainersSet = /* @__PURE__ */ new Set();
|
|
4668
4683
|
for (let i = startBuffered; i <= endBuffered; i++) {
|
|
4669
|
-
const id = (
|
|
4684
|
+
const id = (_m = idCache[i]) != null ? _m : getId(state, i);
|
|
4670
4685
|
if (!containerItemKeys.has(id)) {
|
|
4671
4686
|
needNewContainersSet.add(i);
|
|
4672
4687
|
needNewContainers.push(i);
|
|
@@ -4675,7 +4690,7 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4675
4690
|
if (alwaysRenderArr.length > 0) {
|
|
4676
4691
|
for (const index of alwaysRenderArr) {
|
|
4677
4692
|
if (index < 0 || index >= dataLength) continue;
|
|
4678
|
-
const id = (
|
|
4693
|
+
const id = (_n = idCache[index]) != null ? _n : getId(state, index);
|
|
4679
4694
|
if (id && !containerItemKeys.has(id) && !needNewContainersSet.has(index)) {
|
|
4680
4695
|
needNewContainersSet.add(index);
|
|
4681
4696
|
needNewContainers.push(index);
|
|
@@ -4708,12 +4723,13 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4708
4723
|
endBuffered,
|
|
4709
4724
|
pendingRemoval,
|
|
4710
4725
|
requiredItemTypes,
|
|
4711
|
-
needNewContainers
|
|
4726
|
+
needNewContainers,
|
|
4727
|
+
protectedContainerKeys
|
|
4712
4728
|
);
|
|
4713
4729
|
for (let idx = 0; idx < needNewContainers.length; idx++) {
|
|
4714
4730
|
const i = needNewContainers[idx];
|
|
4715
4731
|
const containerIndex = availableContainers[idx];
|
|
4716
|
-
const id = (
|
|
4732
|
+
const id = (_o = idCache[i]) != null ? _o : getId(state, i);
|
|
4717
4733
|
const oldKey = peek$(ctx, `containerItemKey${containerIndex}`);
|
|
4718
4734
|
if (oldKey && oldKey !== id) {
|
|
4719
4735
|
containerItemKeys.delete(oldKey);
|
|
@@ -4754,7 +4770,7 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4754
4770
|
if (alwaysRenderArr.length > 0) {
|
|
4755
4771
|
for (const index of alwaysRenderArr) {
|
|
4756
4772
|
if (index < 0 || index >= dataLength) continue;
|
|
4757
|
-
const id = (
|
|
4773
|
+
const id = (_p = idCache[index]) != null ? _p : getId(state, index);
|
|
4758
4774
|
const containerIndex = containerItemKeys.get(id);
|
|
4759
4775
|
if (containerIndex !== void 0) {
|
|
4760
4776
|
state.stickyContainerPool.add(containerIndex);
|
|
@@ -4815,16 +4831,18 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4815
4831
|
handleInitialScrollLayoutReady(ctx);
|
|
4816
4832
|
}
|
|
4817
4833
|
if (viewabilityConfigCallbackPairs && startNoBuffer !== null && endNoBuffer !== null) {
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4834
|
+
if (!didMVCPAdjustScroll) {
|
|
4835
|
+
updateViewableItems(
|
|
4836
|
+
ctx.state,
|
|
4837
|
+
ctx,
|
|
4838
|
+
viewabilityConfigCallbackPairs,
|
|
4839
|
+
scrollLength,
|
|
4840
|
+
startNoBuffer,
|
|
4841
|
+
endNoBuffer,
|
|
4842
|
+
startBuffered != null ? startBuffered : startNoBuffer,
|
|
4843
|
+
endBuffered != null ? endBuffered : endNoBuffer
|
|
4844
|
+
);
|
|
4845
|
+
}
|
|
4828
4846
|
}
|
|
4829
4847
|
if (onStickyHeaderChange && stickyIndicesArr.length > 0 && nextActiveStickyIndex !== void 0 && nextActiveStickyIndex !== previousStickyIndex) {
|
|
4830
4848
|
const item = data[nextActiveStickyIndex];
|
package/react-native.web.mjs
CHANGED
|
@@ -4211,7 +4211,7 @@ function computeViewability(state, ctx, viewabilityConfig, containerId, key, scr
|
|
|
4211
4211
|
}
|
|
4212
4212
|
function checkIsViewable(state, ctx, viewabilityConfig, containerId, key, scrollSize, item, index) {
|
|
4213
4213
|
let value = ctx.mapViewabilityAmountValues.get(containerId);
|
|
4214
|
-
if (!value || value.key !== key) {
|
|
4214
|
+
if (!value || value.key !== key || value.index !== index) {
|
|
4215
4215
|
value = computeViewability(state, ctx, viewabilityConfig, containerId, key, scrollSize, item, index);
|
|
4216
4216
|
}
|
|
4217
4217
|
return value.isViewable;
|
|
@@ -4226,7 +4226,7 @@ var unstableBatchedUpdates = ReactDOM.unstable_batchedUpdates;
|
|
|
4226
4226
|
var batchedUpdates = typeof unstableBatchedUpdates === "function" ? unstableBatchedUpdates : (fn) => fn();
|
|
4227
4227
|
|
|
4228
4228
|
// src/utils/findAvailableContainers.ts
|
|
4229
|
-
function findAvailableContainers(ctx, numNeeded, startBuffered, endBuffered, pendingRemoval, requiredItemTypes, needNewContainers) {
|
|
4229
|
+
function findAvailableContainers(ctx, numNeeded, startBuffered, endBuffered, pendingRemoval, requiredItemTypes, needNewContainers, protectedKeys) {
|
|
4230
4230
|
const numContainers = peek$(ctx, "numContainers");
|
|
4231
4231
|
const state = ctx.state;
|
|
4232
4232
|
const { stickyContainerPool, containerItemTypes } = state;
|
|
@@ -4294,6 +4294,7 @@ function findAvailableContainers(ctx, numNeeded, startBuffered, endBuffered, pen
|
|
|
4294
4294
|
}
|
|
4295
4295
|
const key = peek$(ctx, `containerItemKey${u}`);
|
|
4296
4296
|
if (key === void 0) continue;
|
|
4297
|
+
if ((protectedKeys == null ? void 0 : protectedKeys.has(key)) && state.indexByKey.has(key)) continue;
|
|
4297
4298
|
const index = state.indexByKey.get(key);
|
|
4298
4299
|
const isOutOfView = index < startBuffered || index > endBuffered;
|
|
4299
4300
|
if (isOutOfView) {
|
|
@@ -4429,7 +4430,7 @@ function handleStickyRecycling(ctx, stickyArray, scroll, drawDistance, currentSt
|
|
|
4429
4430
|
function calculateItemsInView(ctx, params = {}) {
|
|
4430
4431
|
const state = ctx.state;
|
|
4431
4432
|
batchedUpdates(() => {
|
|
4432
|
-
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
4433
|
+
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
4433
4434
|
const {
|
|
4434
4435
|
columns,
|
|
4435
4436
|
columnSpans,
|
|
@@ -4531,17 +4532,31 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4531
4532
|
if (minIndexSizeChanged !== void 0) {
|
|
4532
4533
|
state.minIndexSizeChanged = void 0;
|
|
4533
4534
|
}
|
|
4535
|
+
let protectedContainerKeys;
|
|
4536
|
+
if (dataChanged && doMVCP && state.props.maintainVisibleContentPosition.data && state.didContainersLayout && state.idsInView.length > 0) {
|
|
4537
|
+
const shouldRestorePosition = state.props.maintainVisibleContentPosition.shouldRestorePosition;
|
|
4538
|
+
protectedContainerKeys = /* @__PURE__ */ new Set();
|
|
4539
|
+
for (const id of state.idsInView) {
|
|
4540
|
+
const index = indexByKey.get(id);
|
|
4541
|
+
if (index === void 0) continue;
|
|
4542
|
+
if (shouldRestorePosition && !shouldRestorePosition(data[index], index, data)) continue;
|
|
4543
|
+
protectedContainerKeys.add(id);
|
|
4544
|
+
}
|
|
4545
|
+
}
|
|
4546
|
+
const scrollBeforeMVCP = state.scroll;
|
|
4547
|
+
const scrollAdjustPendingBeforeMVCP = (_e = peek$(ctx, "scrollAdjustPending")) != null ? _e : 0;
|
|
4534
4548
|
checkMVCP == null ? void 0 : checkMVCP();
|
|
4549
|
+
const didMVCPAdjustScroll = !!checkMVCP && (state.scroll !== scrollBeforeMVCP || ((_f = peek$(ctx, "scrollAdjustPending")) != null ? _f : 0) !== scrollAdjustPendingBeforeMVCP);
|
|
4535
4550
|
let startNoBuffer = null;
|
|
4536
4551
|
let startBuffered = null;
|
|
4537
4552
|
let startBufferedId = null;
|
|
4538
4553
|
let endNoBuffer = null;
|
|
4539
4554
|
let endBuffered = null;
|
|
4540
|
-
let loopStart = (
|
|
4555
|
+
let loopStart = (_g = suppressInitialScrollSideEffects ? bootstrapInitialScrollState == null ? void 0 : bootstrapInitialScrollState.targetIndexSeed : void 0) != null ? _g : !dataChanged && startBufferedIdOrig ? indexByKey.get(startBufferedIdOrig) || 0 : 0;
|
|
4541
4556
|
for (let i = loopStart; i >= 0; i--) {
|
|
4542
|
-
const id = (
|
|
4557
|
+
const id = (_h = idCache[i]) != null ? _h : getId(state, i);
|
|
4543
4558
|
const top = positions[i];
|
|
4544
|
-
const size = (
|
|
4559
|
+
const size = (_i = sizes.get(id)) != null ? _i : getItemSize(ctx, id, i, data[i]);
|
|
4545
4560
|
const bottom = top + size;
|
|
4546
4561
|
if (bottom > scroll - scrollBufferTop) {
|
|
4547
4562
|
loopStart = i;
|
|
@@ -4572,8 +4587,8 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4572
4587
|
let firstFullyOnScreenIndex;
|
|
4573
4588
|
const dataLength = data.length;
|
|
4574
4589
|
for (let i = Math.max(0, loopStart); i < dataLength && (!foundEnd || i <= maxIndexRendered); i++) {
|
|
4575
|
-
const id = (
|
|
4576
|
-
const size = (
|
|
4590
|
+
const id = (_j = idCache[i]) != null ? _j : getId(state, i);
|
|
4591
|
+
const size = (_k = sizes.get(id)) != null ? _k : getItemSize(ctx, id, i, data[i]);
|
|
4577
4592
|
const top = positions[i];
|
|
4578
4593
|
if (!foundEnd) {
|
|
4579
4594
|
if (startNoBuffer === null && top + size > scroll) {
|
|
@@ -4612,7 +4627,7 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4612
4627
|
const firstVisibleAnchorIndex = firstFullyOnScreenIndex != null ? firstFullyOnScreenIndex : startNoBuffer;
|
|
4613
4628
|
if (firstVisibleAnchorIndex !== null && firstVisibleAnchorIndex !== void 0 && endNoBuffer !== null) {
|
|
4614
4629
|
for (let i = firstVisibleAnchorIndex; i <= endNoBuffer; i++) {
|
|
4615
|
-
const id = (
|
|
4630
|
+
const id = (_l = idCache[i]) != null ? _l : getId(state, i);
|
|
4616
4631
|
idsInView.push(id);
|
|
4617
4632
|
}
|
|
4618
4633
|
}
|
|
@@ -4645,7 +4660,7 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4645
4660
|
const needNewContainers = [];
|
|
4646
4661
|
const needNewContainersSet = /* @__PURE__ */ new Set();
|
|
4647
4662
|
for (let i = startBuffered; i <= endBuffered; i++) {
|
|
4648
|
-
const id = (
|
|
4663
|
+
const id = (_m = idCache[i]) != null ? _m : getId(state, i);
|
|
4649
4664
|
if (!containerItemKeys.has(id)) {
|
|
4650
4665
|
needNewContainersSet.add(i);
|
|
4651
4666
|
needNewContainers.push(i);
|
|
@@ -4654,7 +4669,7 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4654
4669
|
if (alwaysRenderArr.length > 0) {
|
|
4655
4670
|
for (const index of alwaysRenderArr) {
|
|
4656
4671
|
if (index < 0 || index >= dataLength) continue;
|
|
4657
|
-
const id = (
|
|
4672
|
+
const id = (_n = idCache[index]) != null ? _n : getId(state, index);
|
|
4658
4673
|
if (id && !containerItemKeys.has(id) && !needNewContainersSet.has(index)) {
|
|
4659
4674
|
needNewContainersSet.add(index);
|
|
4660
4675
|
needNewContainers.push(index);
|
|
@@ -4687,12 +4702,13 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4687
4702
|
endBuffered,
|
|
4688
4703
|
pendingRemoval,
|
|
4689
4704
|
requiredItemTypes,
|
|
4690
|
-
needNewContainers
|
|
4705
|
+
needNewContainers,
|
|
4706
|
+
protectedContainerKeys
|
|
4691
4707
|
);
|
|
4692
4708
|
for (let idx = 0; idx < needNewContainers.length; idx++) {
|
|
4693
4709
|
const i = needNewContainers[idx];
|
|
4694
4710
|
const containerIndex = availableContainers[idx];
|
|
4695
|
-
const id = (
|
|
4711
|
+
const id = (_o = idCache[i]) != null ? _o : getId(state, i);
|
|
4696
4712
|
const oldKey = peek$(ctx, `containerItemKey${containerIndex}`);
|
|
4697
4713
|
if (oldKey && oldKey !== id) {
|
|
4698
4714
|
containerItemKeys.delete(oldKey);
|
|
@@ -4733,7 +4749,7 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4733
4749
|
if (alwaysRenderArr.length > 0) {
|
|
4734
4750
|
for (const index of alwaysRenderArr) {
|
|
4735
4751
|
if (index < 0 || index >= dataLength) continue;
|
|
4736
|
-
const id = (
|
|
4752
|
+
const id = (_p = idCache[index]) != null ? _p : getId(state, index);
|
|
4737
4753
|
const containerIndex = containerItemKeys.get(id);
|
|
4738
4754
|
if (containerIndex !== void 0) {
|
|
4739
4755
|
state.stickyContainerPool.add(containerIndex);
|
|
@@ -4794,16 +4810,18 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4794
4810
|
handleInitialScrollLayoutReady(ctx);
|
|
4795
4811
|
}
|
|
4796
4812
|
if (viewabilityConfigCallbackPairs && startNoBuffer !== null && endNoBuffer !== null) {
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4813
|
+
if (!didMVCPAdjustScroll) {
|
|
4814
|
+
updateViewableItems(
|
|
4815
|
+
ctx.state,
|
|
4816
|
+
ctx,
|
|
4817
|
+
viewabilityConfigCallbackPairs,
|
|
4818
|
+
scrollLength,
|
|
4819
|
+
startNoBuffer,
|
|
4820
|
+
endNoBuffer,
|
|
4821
|
+
startBuffered != null ? startBuffered : startNoBuffer,
|
|
4822
|
+
endBuffered != null ? endBuffered : endNoBuffer
|
|
4823
|
+
);
|
|
4824
|
+
}
|
|
4807
4825
|
}
|
|
4808
4826
|
if (onStickyHeaderChange && stickyIndicesArr.length > 0 && nextActiveStickyIndex !== void 0 && nextActiveStickyIndex !== previousStickyIndex) {
|
|
4809
4827
|
const item = data[nextActiveStickyIndex];
|