@legendapp/list 3.0.0-beta.32 → 3.0.0-beta.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -1
- package/animated.d.ts +605 -6
- package/animated.js +2 -2
- package/animated.mjs +1 -1
- package/index.d.ts +503 -118
- package/index.js +607 -275
- package/index.mjs +607 -275
- package/index.native.js +348 -189
- package/index.native.mjs +347 -188
- package/keyboard-controller.d.ts +616 -6
- package/keyboard-controller.js +2 -2
- package/keyboard-controller.mjs +1 -1
- package/keyboard.d.ts +204 -8
- package/keyboard.js +68 -53
- package/keyboard.mjs +71 -55
- package/{index.d.mts → list-react-native.d.ts} +138 -42
- package/list-react-native.js +4348 -0
- package/list-react-native.mjs +4318 -0
- package/{index.native.d.mts → list-react.d.ts} +195 -42
- package/list-react.js +4709 -0
- package/list-react.mjs +4679 -0
- package/package.json +52 -1
- package/reanimated.d.ts +605 -7
- package/reanimated.js +180 -12
- package/reanimated.mjs +177 -9
- package/section-list.d.ts +615 -14
- package/section-list.js +6 -6
- package/section-list.mjs +1 -1
- package/animated.d.mts +0 -9
- package/animated.native.d.mts +0 -9
- package/animated.native.d.ts +0 -9
- package/animated.native.js +0 -9
- package/animated.native.mjs +0 -7
- package/index.native.d.ts +0 -817
- package/keyboard-controller.d.mts +0 -12
- package/keyboard-controller.native.d.mts +0 -12
- package/keyboard-controller.native.d.ts +0 -12
- package/keyboard-controller.native.js +0 -69
- package/keyboard-controller.native.mjs +0 -48
- package/keyboard.d.mts +0 -13
- package/keyboard.native.d.mts +0 -13
- package/keyboard.native.d.ts +0 -13
- package/keyboard.native.js +0 -399
- package/keyboard.native.mjs +0 -377
- package/reanimated.d.mts +0 -18
- package/reanimated.native.d.mts +0 -18
- package/reanimated.native.d.ts +0 -18
- package/reanimated.native.js +0 -89
- package/reanimated.native.mjs +0 -65
- package/section-list.d.mts +0 -112
- package/section-list.native.d.mts +0 -112
- package/section-list.native.d.ts +0 -112
- package/section-list.native.js +0 -293
- package/section-list.native.mjs +0 -271
package/index.native.js
CHANGED
|
@@ -239,7 +239,7 @@ var _a;
|
|
|
239
239
|
var envMode = typeof process !== "undefined" && typeof process.env === "object" && process.env ? (_a = process.env.NODE_ENV) != null ? _a : process.env.MODE : void 0;
|
|
240
240
|
var processDev = typeof envMode === "string" ? envMode.toLowerCase() !== "production" : void 0;
|
|
241
241
|
var _a2;
|
|
242
|
-
var IS_DEV = (_a2 =
|
|
242
|
+
var IS_DEV = (_a2 = processDev != null ? processDev : metroDev) != null ? _a2 : false;
|
|
243
243
|
|
|
244
244
|
// src/constants.ts
|
|
245
245
|
var POSITION_OUT_OF_VIEW = -1e7;
|
|
@@ -312,7 +312,7 @@ function useValue$(key, params) {
|
|
|
312
312
|
React2.useMemo(() => {
|
|
313
313
|
let prevValue;
|
|
314
314
|
let didQueueTask = false;
|
|
315
|
-
listen$(ctx, key, (
|
|
315
|
+
listen$(ctx, key, () => {
|
|
316
316
|
const newValue = getNewValue();
|
|
317
317
|
if (delay !== void 0) {
|
|
318
318
|
const fn = () => {
|
|
@@ -341,7 +341,6 @@ function useValue$(key, params) {
|
|
|
341
341
|
}, []);
|
|
342
342
|
return animValue;
|
|
343
343
|
}
|
|
344
|
-
var typedForwardRef = React2.forwardRef;
|
|
345
344
|
var typedMemo = React2.memo;
|
|
346
345
|
var getComponent = (Component) => {
|
|
347
346
|
if (React2__namespace.isValidElement(Component)) {
|
|
@@ -416,10 +415,7 @@ var PositionViewSticky = typedMemo(function PositionViewSticky2({
|
|
|
416
415
|
const stickyPosition = animatedScrollY.interpolate({
|
|
417
416
|
extrapolateLeft: "clamp",
|
|
418
417
|
extrapolateRight: "extend",
|
|
419
|
-
inputRange: [
|
|
420
|
-
stickyStart,
|
|
421
|
-
stickyStart + 5e3
|
|
422
|
-
],
|
|
418
|
+
inputRange: [stickyStart, stickyStart + 5e3],
|
|
423
419
|
outputRange: [position, position + 5e3]
|
|
424
420
|
});
|
|
425
421
|
return horizontal ? [{ translateX: stickyPosition }] : [{ translateY: stickyPosition }];
|
|
@@ -637,6 +633,8 @@ function useOnLayoutSync({
|
|
|
637
633
|
}
|
|
638
634
|
var Platform2 = reactNative.Platform;
|
|
639
635
|
var PlatformAdjustBreaksScroll = Platform2.OS === "android";
|
|
636
|
+
var typedForwardRef = React2.forwardRef;
|
|
637
|
+
var typedMemo2 = React2.memo;
|
|
640
638
|
|
|
641
639
|
// src/utils/isInMVCPActiveMode.native.ts
|
|
642
640
|
function isInMVCPActiveMode(state) {
|
|
@@ -644,7 +642,7 @@ function isInMVCPActiveMode(state) {
|
|
|
644
642
|
}
|
|
645
643
|
|
|
646
644
|
// src/components/Container.tsx
|
|
647
|
-
var Container =
|
|
645
|
+
var Container = typedMemo2(function Container2({
|
|
648
646
|
id,
|
|
649
647
|
recycleItems,
|
|
650
648
|
horizontal,
|
|
@@ -655,6 +653,8 @@ var Container = typedMemo(function Container2({
|
|
|
655
653
|
}) {
|
|
656
654
|
const ctx = useStateContext();
|
|
657
655
|
const { columnWrapperStyle, animatedScrollY } = ctx;
|
|
656
|
+
const positionComponentInternal = ctx.state.props.positionComponentInternal;
|
|
657
|
+
const stickyPositionComponentInternal = ctx.state.props.stickyPositionComponentInternal;
|
|
658
658
|
const [column = 0, span = 1, data, itemKey, numColumns = 1, extraData, isSticky] = useArr$([
|
|
659
659
|
`containerColumn${id}`,
|
|
660
660
|
`containerSpan${id}`,
|
|
@@ -807,7 +807,7 @@ var Container = typedMemo(function Container2({
|
|
|
807
807
|
}
|
|
808
808
|
}, [itemKey]);
|
|
809
809
|
}
|
|
810
|
-
const PositionComponent = isSticky ? PositionViewSticky : PositionView;
|
|
810
|
+
const PositionComponent = isSticky ? stickyPositionComponentInternal ? stickyPositionComponentInternal : PositionViewSticky : positionComponentInternal ? positionComponentInternal : PositionView;
|
|
811
811
|
return /* @__PURE__ */ React2__namespace.createElement(
|
|
812
812
|
PositionComponent,
|
|
813
813
|
{
|
|
@@ -918,7 +918,7 @@ var LayoutView = ({ onLayoutChange, refView, ...rest }) => {
|
|
|
918
918
|
};
|
|
919
919
|
|
|
920
920
|
// src/components/ListComponent.tsx
|
|
921
|
-
var ListComponent =
|
|
921
|
+
var ListComponent = typedMemo2(function ListComponent2({
|
|
922
922
|
canRender,
|
|
923
923
|
style,
|
|
924
924
|
contentContainerStyle,
|
|
@@ -944,12 +944,15 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
944
944
|
snapToIndices,
|
|
945
945
|
stickyHeaderConfig,
|
|
946
946
|
stickyHeaderIndices,
|
|
947
|
+
useWindowScroll = false,
|
|
947
948
|
...rest
|
|
948
949
|
}) {
|
|
949
950
|
const ctx = useStateContext();
|
|
950
951
|
const maintainVisibleContentPosition = ctx.state.props.maintainVisibleContentPosition;
|
|
951
952
|
const ScrollComponent = renderScrollComponent ? React2.useMemo(
|
|
952
|
-
() => React2__namespace.forwardRef(
|
|
953
|
+
() => React2__namespace.forwardRef(
|
|
954
|
+
(props, ref) => renderScrollComponent({ ...props, ref })
|
|
955
|
+
),
|
|
953
956
|
[renderScrollComponent]
|
|
954
957
|
) : ListComponentScrollView;
|
|
955
958
|
const SnapOrScroll = snapToIndices ? SnapWrapper : ScrollComponent;
|
|
@@ -965,6 +968,7 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
965
968
|
SnapOrScroll,
|
|
966
969
|
{
|
|
967
970
|
...rest,
|
|
971
|
+
...ScrollComponent === ListComponentScrollView ? { useWindowScroll } : {},
|
|
968
972
|
contentContainerStyle: [
|
|
969
973
|
contentContainerStyle,
|
|
970
974
|
horizontal ? {
|
|
@@ -1010,24 +1014,12 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
1010
1014
|
);
|
|
1011
1015
|
});
|
|
1012
1016
|
|
|
1013
|
-
// src/utils/getId.ts
|
|
1014
|
-
function getId(state, index) {
|
|
1015
|
-
const { data, keyExtractor } = state.props;
|
|
1016
|
-
if (!data) {
|
|
1017
|
-
return "";
|
|
1018
|
-
}
|
|
1019
|
-
const ret = index < data.length ? keyExtractor ? keyExtractor(data[index], index) : index : null;
|
|
1020
|
-
const id = ret;
|
|
1021
|
-
state.idCache[index] = id;
|
|
1022
|
-
return id;
|
|
1023
|
-
}
|
|
1024
|
-
|
|
1025
1017
|
// src/core/calculateOffsetForIndex.ts
|
|
1026
1018
|
function calculateOffsetForIndex(ctx, index) {
|
|
1027
1019
|
const state = ctx.state;
|
|
1028
1020
|
let position = 0;
|
|
1029
1021
|
if (index !== void 0) {
|
|
1030
|
-
position = state.positions
|
|
1022
|
+
position = state.positions[index] || 0;
|
|
1031
1023
|
const paddingTop = peek$(ctx, "stylePaddingTop");
|
|
1032
1024
|
if (paddingTop) {
|
|
1033
1025
|
position += paddingTop;
|
|
@@ -1040,6 +1032,18 @@ function calculateOffsetForIndex(ctx, index) {
|
|
|
1040
1032
|
return position;
|
|
1041
1033
|
}
|
|
1042
1034
|
|
|
1035
|
+
// src/utils/getId.ts
|
|
1036
|
+
function getId(state, index) {
|
|
1037
|
+
const { data, keyExtractor } = state.props;
|
|
1038
|
+
if (!data) {
|
|
1039
|
+
return "";
|
|
1040
|
+
}
|
|
1041
|
+
const ret = index < data.length ? keyExtractor ? keyExtractor(data[index], index) : index : null;
|
|
1042
|
+
const id = ret;
|
|
1043
|
+
state.idCache[index] = id;
|
|
1044
|
+
return id;
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1043
1047
|
// src/core/addTotalSize.ts
|
|
1044
1048
|
function addTotalSize(ctx, key, add) {
|
|
1045
1049
|
const state = ctx.state;
|
|
@@ -1093,13 +1097,13 @@ function getItemSize(ctx, key, index, data, useAverageSize, preferCachedSize) {
|
|
|
1093
1097
|
return sizeKnown;
|
|
1094
1098
|
}
|
|
1095
1099
|
let size;
|
|
1096
|
-
const itemType = getItemType ? (_a3 = getItemType(data, index)) != null ? _a3 : "" : "";
|
|
1097
1100
|
if (preferCachedSize) {
|
|
1098
1101
|
const cachedSize = sizes.get(key);
|
|
1099
1102
|
if (cachedSize !== void 0) {
|
|
1100
1103
|
return cachedSize;
|
|
1101
1104
|
}
|
|
1102
1105
|
}
|
|
1106
|
+
const itemType = getItemType ? (_a3 = getItemType(data, index)) != null ? _a3 : "" : "";
|
|
1103
1107
|
if (getFixedItemSize) {
|
|
1104
1108
|
size = getFixedItemSize(data, index, itemType);
|
|
1105
1109
|
if (size !== void 0) {
|
|
@@ -1142,12 +1146,15 @@ function calculateOffsetWithOffsetPosition(ctx, offsetParam, params) {
|
|
|
1142
1146
|
}
|
|
1143
1147
|
|
|
1144
1148
|
// src/core/clampScrollOffset.ts
|
|
1145
|
-
function clampScrollOffset(ctx, offset) {
|
|
1149
|
+
function clampScrollOffset(ctx, offset, scrollTarget) {
|
|
1146
1150
|
const state = ctx.state;
|
|
1147
1151
|
const contentSize = getContentSize(ctx);
|
|
1148
1152
|
let clampedOffset = offset;
|
|
1149
1153
|
if (Number.isFinite(contentSize) && Number.isFinite(state.scrollLength) && (Platform2.OS !== "android" || state.lastLayout)) {
|
|
1150
|
-
const
|
|
1154
|
+
const baseMaxOffset = Math.max(0, contentSize - state.scrollLength);
|
|
1155
|
+
const viewOffset = scrollTarget == null ? void 0 : scrollTarget.viewOffset;
|
|
1156
|
+
const extraEndOffset = typeof viewOffset === "number" && viewOffset < 0 ? -viewOffset : 0;
|
|
1157
|
+
const maxOffset = baseMaxOffset + extraEndOffset;
|
|
1151
1158
|
clampedOffset = Math.min(offset, maxOffset);
|
|
1152
1159
|
}
|
|
1153
1160
|
clampedOffset = Math.max(0, clampedOffset);
|
|
@@ -1240,37 +1247,54 @@ function checkAtBottom(ctx) {
|
|
|
1240
1247
|
|
|
1241
1248
|
// src/utils/checkAtTop.ts
|
|
1242
1249
|
function checkAtTop(ctx) {
|
|
1243
|
-
var _a3;
|
|
1244
1250
|
const state = ctx == null ? void 0 : ctx.state;
|
|
1245
|
-
if (!state || state.initialScroll) {
|
|
1251
|
+
if (!state || state.initialScroll || state.scrollingTo) {
|
|
1246
1252
|
return;
|
|
1247
1253
|
}
|
|
1248
1254
|
const {
|
|
1249
|
-
|
|
1255
|
+
dataChangeEpoch,
|
|
1256
|
+
isStartReached,
|
|
1257
|
+
props: { data, onStartReachedThreshold },
|
|
1250
1258
|
scroll,
|
|
1251
|
-
|
|
1259
|
+
scrollLength,
|
|
1260
|
+
startReachedSnapshot,
|
|
1261
|
+
startReachedSnapshotDataChangeEpoch,
|
|
1262
|
+
totalSize
|
|
1252
1263
|
} = state;
|
|
1253
|
-
const
|
|
1254
|
-
|
|
1264
|
+
const dataLength = data.length;
|
|
1265
|
+
const threshold = onStartReachedThreshold * scrollLength;
|
|
1266
|
+
const dataChanged = startReachedSnapshotDataChangeEpoch !== dataChangeEpoch;
|
|
1267
|
+
const withinThreshold = threshold > 0 && Math.abs(scroll) <= threshold;
|
|
1268
|
+
const allowReentryOnDataChange = !!isStartReached && withinThreshold && !!dataChanged && !isInMVCPActiveMode(state);
|
|
1269
|
+
if (isStartReached && threshold > 0 && scroll > threshold && startReachedSnapshot && (dataChanged || startReachedSnapshot.contentSize !== totalSize || startReachedSnapshot.dataLength !== dataLength)) {
|
|
1270
|
+
state.isStartReached = false;
|
|
1271
|
+
state.startReachedSnapshot = void 0;
|
|
1272
|
+
state.startReachedSnapshotDataChangeEpoch = void 0;
|
|
1273
|
+
}
|
|
1274
|
+
state.isAtStart = scroll <= 0;
|
|
1275
|
+
if (isStartReached && withinThreshold && dataChanged && !allowReentryOnDataChange) {
|
|
1276
|
+
return;
|
|
1277
|
+
}
|
|
1255
1278
|
state.isStartReached = checkThreshold(
|
|
1256
|
-
|
|
1279
|
+
scroll,
|
|
1257
1280
|
false,
|
|
1258
|
-
|
|
1281
|
+
threshold,
|
|
1259
1282
|
state.isStartReached,
|
|
1260
|
-
|
|
1283
|
+
allowReentryOnDataChange ? void 0 : startReachedSnapshot,
|
|
1261
1284
|
{
|
|
1262
|
-
contentSize:
|
|
1263
|
-
dataLength
|
|
1285
|
+
contentSize: totalSize,
|
|
1286
|
+
dataLength,
|
|
1264
1287
|
scrollPosition: scroll
|
|
1265
1288
|
},
|
|
1266
1289
|
(distance) => {
|
|
1267
|
-
var
|
|
1268
|
-
return (_b = (
|
|
1290
|
+
var _a3, _b;
|
|
1291
|
+
return (_b = (_a3 = state.props).onStartReached) == null ? void 0 : _b.call(_a3, { distanceFromStart: distance });
|
|
1269
1292
|
},
|
|
1270
1293
|
(snapshot) => {
|
|
1271
1294
|
state.startReachedSnapshot = snapshot;
|
|
1295
|
+
state.startReachedSnapshotDataChangeEpoch = snapshot ? dataChangeEpoch : void 0;
|
|
1272
1296
|
},
|
|
1273
|
-
|
|
1297
|
+
allowReentryOnDataChange
|
|
1274
1298
|
);
|
|
1275
1299
|
}
|
|
1276
1300
|
|
|
@@ -1286,14 +1310,22 @@ function setInitialRenderState(ctx, {
|
|
|
1286
1310
|
didInitialScroll
|
|
1287
1311
|
}) {
|
|
1288
1312
|
const { state } = ctx;
|
|
1313
|
+
const {
|
|
1314
|
+
loadStartTime,
|
|
1315
|
+
props: { onLoad }
|
|
1316
|
+
} = state;
|
|
1289
1317
|
if (didLayout) {
|
|
1290
1318
|
state.didContainersLayout = true;
|
|
1291
1319
|
}
|
|
1292
1320
|
if (didInitialScroll) {
|
|
1293
1321
|
state.didFinishInitialScroll = true;
|
|
1294
1322
|
}
|
|
1295
|
-
|
|
1323
|
+
const isReadyToRender = Boolean(state.didContainersLayout && state.didFinishInitialScroll);
|
|
1324
|
+
if (isReadyToRender && !peek$(ctx, "readyToRender")) {
|
|
1296
1325
|
set$(ctx, "readyToRender", true);
|
|
1326
|
+
if (onLoad) {
|
|
1327
|
+
onLoad({ elapsedTimeInMs: Date.now() - loadStartTime });
|
|
1328
|
+
}
|
|
1297
1329
|
}
|
|
1298
1330
|
}
|
|
1299
1331
|
|
|
@@ -1302,6 +1334,8 @@ function finishScrollTo(ctx) {
|
|
|
1302
1334
|
var _a3, _b;
|
|
1303
1335
|
const state = ctx.state;
|
|
1304
1336
|
if (state == null ? void 0 : state.scrollingTo) {
|
|
1337
|
+
const resolvePendingScroll = state.pendingScrollResolve;
|
|
1338
|
+
state.pendingScrollResolve = void 0;
|
|
1305
1339
|
const scrollingTo = state.scrollingTo;
|
|
1306
1340
|
state.scrollHistory.length = 0;
|
|
1307
1341
|
state.initialScroll = void 0;
|
|
@@ -1318,6 +1352,7 @@ function finishScrollTo(ctx) {
|
|
|
1318
1352
|
}
|
|
1319
1353
|
setInitialRenderState(ctx, { didInitialScroll: true });
|
|
1320
1354
|
checkThresholds(ctx);
|
|
1355
|
+
resolvePendingScroll == null ? void 0 : resolvePendingScroll();
|
|
1321
1356
|
}
|
|
1322
1357
|
}
|
|
1323
1358
|
|
|
@@ -1332,8 +1367,12 @@ function checkFinishedScrollFrame(ctx) {
|
|
|
1332
1367
|
state.animFrameCheckFinishedScroll = void 0;
|
|
1333
1368
|
const scroll = state.scrollPending;
|
|
1334
1369
|
const adjust = state.scrollAdjustHandler.getAdjust();
|
|
1335
|
-
const clampedTargetOffset = clampScrollOffset(
|
|
1336
|
-
|
|
1370
|
+
const clampedTargetOffset = clampScrollOffset(
|
|
1371
|
+
ctx,
|
|
1372
|
+
scrollingTo.offset - (scrollingTo.viewOffset || 0),
|
|
1373
|
+
scrollingTo
|
|
1374
|
+
);
|
|
1375
|
+
const maxOffset = clampScrollOffset(ctx, scroll, scrollingTo);
|
|
1337
1376
|
const diff1 = Math.abs(scroll - clampedTargetOffset);
|
|
1338
1377
|
const diff2 = Math.abs(diff1 - adjust);
|
|
1339
1378
|
const isNotOverscrolled = Math.abs(scroll - maxOffset) < 1;
|
|
@@ -1370,16 +1409,20 @@ function checkFinishedScrollFallback(ctx) {
|
|
|
1370
1409
|
|
|
1371
1410
|
// src/core/doScrollTo.native.ts
|
|
1372
1411
|
function doScrollTo(ctx, params) {
|
|
1373
|
-
var _a3;
|
|
1374
1412
|
const state = ctx.state;
|
|
1375
1413
|
const { animated, horizontal, offset } = params;
|
|
1414
|
+
const isAnimated = !!animated;
|
|
1376
1415
|
const { refScroller } = state;
|
|
1377
|
-
|
|
1378
|
-
|
|
1416
|
+
const scroller = refScroller.current;
|
|
1417
|
+
if (!scroller) {
|
|
1418
|
+
return;
|
|
1419
|
+
}
|
|
1420
|
+
scroller.scrollTo({
|
|
1421
|
+
animated: isAnimated,
|
|
1379
1422
|
x: horizontal ? offset : 0,
|
|
1380
1423
|
y: horizontal ? 0 : offset
|
|
1381
1424
|
});
|
|
1382
|
-
if (!
|
|
1425
|
+
if (!isAnimated) {
|
|
1383
1426
|
state.scroll = offset;
|
|
1384
1427
|
checkFinishedScrollFallback(ctx);
|
|
1385
1428
|
}
|
|
@@ -1400,7 +1443,7 @@ function scrollTo(ctx, params) {
|
|
|
1400
1443
|
clearTimeout(ctx.state.timeoutCheckFinishedScrollFallback);
|
|
1401
1444
|
}
|
|
1402
1445
|
let offset = precomputedWithViewOffset ? scrollTargetOffset : calculateOffsetWithOffsetPosition(ctx, scrollTargetOffset, scrollTarget);
|
|
1403
|
-
offset = clampScrollOffset(ctx, offset);
|
|
1446
|
+
offset = clampScrollOffset(ctx, offset, scrollTarget);
|
|
1404
1447
|
state.scrollHistory.length = 0;
|
|
1405
1448
|
if (!noScrollingTo) {
|
|
1406
1449
|
state.scrollingTo = scrollTarget;
|
|
@@ -1421,7 +1464,7 @@ var flushSync = (fn) => {
|
|
|
1421
1464
|
// src/core/updateScroll.ts
|
|
1422
1465
|
function updateScroll(ctx, newScroll, forceUpdate) {
|
|
1423
1466
|
const state = ctx.state;
|
|
1424
|
-
const {
|
|
1467
|
+
const { ignoreScrollFromMVCP, lastScrollAdjustForHistory, scrollAdjustHandler, scrollHistory, scrollingTo } = state;
|
|
1425
1468
|
const prevScroll = state.scroll;
|
|
1426
1469
|
state.hasScrolled = true;
|
|
1427
1470
|
state.lastBatchingAction = Date.now();
|
|
@@ -1429,22 +1472,17 @@ function updateScroll(ctx, newScroll, forceUpdate) {
|
|
|
1429
1472
|
const adjust = scrollAdjustHandler.getAdjust();
|
|
1430
1473
|
const adjustChanged = lastScrollAdjustForHistory !== void 0 && Math.abs(adjust - lastScrollAdjustForHistory) > 0.1;
|
|
1431
1474
|
if (adjustChanged) {
|
|
1432
|
-
|
|
1475
|
+
scrollHistory.length = 0;
|
|
1433
1476
|
}
|
|
1434
1477
|
state.lastScrollAdjustForHistory = adjust;
|
|
1435
|
-
if (scrollingTo === void 0 && !(
|
|
1478
|
+
if (scrollingTo === void 0 && !(scrollHistory.length === 0 && newScroll === state.scroll)) {
|
|
1436
1479
|
if (!adjustChanged) {
|
|
1437
|
-
|
|
1480
|
+
scrollHistory.push({ scroll: newScroll, time: currentTime });
|
|
1438
1481
|
}
|
|
1439
1482
|
}
|
|
1440
|
-
if (
|
|
1441
|
-
|
|
1483
|
+
if (scrollHistory.length > 5) {
|
|
1484
|
+
scrollHistory.shift();
|
|
1442
1485
|
}
|
|
1443
|
-
state.scrollPrev = prevScroll;
|
|
1444
|
-
state.scrollPrevTime = state.scrollTime;
|
|
1445
|
-
state.scroll = newScroll;
|
|
1446
|
-
state.scrollTime = currentTime;
|
|
1447
|
-
const ignoreScrollFromMVCP = state.ignoreScrollFromMVCP;
|
|
1448
1486
|
if (ignoreScrollFromMVCP && !scrollingTo) {
|
|
1449
1487
|
const { lt, gt } = ignoreScrollFromMVCP;
|
|
1450
1488
|
if (lt && newScroll < lt || gt && newScroll > gt) {
|
|
@@ -1452,6 +1490,10 @@ function updateScroll(ctx, newScroll, forceUpdate) {
|
|
|
1452
1490
|
return;
|
|
1453
1491
|
}
|
|
1454
1492
|
}
|
|
1493
|
+
state.scrollPrev = prevScroll;
|
|
1494
|
+
state.scrollPrevTime = state.scrollTime;
|
|
1495
|
+
state.scroll = newScroll;
|
|
1496
|
+
state.scrollTime = currentTime;
|
|
1455
1497
|
const scrollDelta = Math.abs(newScroll - prevScroll);
|
|
1456
1498
|
const scrollLength = state.scrollLength;
|
|
1457
1499
|
const lastCalculated = state.scrollLastCalculate;
|
|
@@ -1537,14 +1579,14 @@ var INITIAL_ANCHOR_SETTLED_TICKS = 2;
|
|
|
1537
1579
|
function ensureInitialAnchor(ctx) {
|
|
1538
1580
|
var _a3, _b, _c, _d, _e;
|
|
1539
1581
|
const state = ctx.state;
|
|
1540
|
-
const { initialAnchor, didContainersLayout,
|
|
1582
|
+
const { initialAnchor, didContainersLayout, scroll, scrollLength } = state;
|
|
1541
1583
|
const anchor = initialAnchor;
|
|
1542
1584
|
const item = state.props.data[anchor.index];
|
|
1543
1585
|
if (!didContainersLayout) {
|
|
1544
1586
|
return;
|
|
1545
1587
|
}
|
|
1546
1588
|
const id = getId(state, anchor.index);
|
|
1547
|
-
if (positions.
|
|
1589
|
+
if (state.positions[anchor.index] === void 0) {
|
|
1548
1590
|
return;
|
|
1549
1591
|
}
|
|
1550
1592
|
const size = getItemSize(ctx, id, anchor.index, item, true, true);
|
|
@@ -1553,7 +1595,7 @@ function ensureInitialAnchor(ctx) {
|
|
|
1553
1595
|
}
|
|
1554
1596
|
const availableSpace = Math.max(0, scrollLength - size);
|
|
1555
1597
|
const desiredOffset = calculateOffsetForIndex(ctx, anchor.index) - ((_a3 = anchor.viewOffset) != null ? _a3 : 0) - ((_b = anchor.viewPosition) != null ? _b : 0) * availableSpace;
|
|
1556
|
-
const clampedDesiredOffset = clampScrollOffset(ctx, desiredOffset);
|
|
1598
|
+
const clampedDesiredOffset = clampScrollOffset(ctx, desiredOffset, anchor);
|
|
1557
1599
|
const delta = clampedDesiredOffset - scroll;
|
|
1558
1600
|
if (Math.abs(delta) <= INITIAL_ANCHOR_TOLERANCE) {
|
|
1559
1601
|
const settledTicks = ((_c = anchor.settledTicks) != null ? _c : 0) + 1;
|
|
@@ -1640,6 +1682,7 @@ function prepareMVCP(ctx, dataChanged) {
|
|
|
1640
1682
|
const idsInViewWithPositions = [];
|
|
1641
1683
|
const scrollTarget = scrollingTo == null ? void 0 : scrollingTo.index;
|
|
1642
1684
|
const scrollingToViewPosition = scrollingTo == null ? void 0 : scrollingTo.viewPosition;
|
|
1685
|
+
const isEndAnchoredScrollTarget = scrollTarget !== void 0 && state.props.data.length > 0 && scrollTarget >= state.props.data.length - 1 && (scrollingToViewPosition != null ? scrollingToViewPosition : 0) > 0;
|
|
1643
1686
|
const shouldMVCP = dataChanged ? mvcpData : mvcpScroll;
|
|
1644
1687
|
const indexByKey = state.indexByKey;
|
|
1645
1688
|
if (shouldMVCP) {
|
|
@@ -1659,12 +1702,18 @@ function prepareMVCP(ctx, dataChanged) {
|
|
|
1659
1702
|
const id = idsInView[i];
|
|
1660
1703
|
const index = indexByKey.get(id);
|
|
1661
1704
|
if (index !== void 0) {
|
|
1662
|
-
|
|
1705
|
+
const position = positions[index];
|
|
1706
|
+
if (position !== void 0) {
|
|
1707
|
+
idsInViewWithPositions.push({ id, position });
|
|
1708
|
+
}
|
|
1663
1709
|
}
|
|
1664
1710
|
}
|
|
1665
1711
|
}
|
|
1666
1712
|
if (targetId !== void 0 && prevPosition === void 0) {
|
|
1667
|
-
|
|
1713
|
+
const targetIndex = indexByKey.get(targetId);
|
|
1714
|
+
if (targetIndex !== void 0) {
|
|
1715
|
+
prevPosition = positions[targetIndex];
|
|
1716
|
+
}
|
|
1668
1717
|
}
|
|
1669
1718
|
return () => {
|
|
1670
1719
|
let positionDiff = 0;
|
|
@@ -1683,7 +1732,13 @@ function prepareMVCP(ctx, dataChanged) {
|
|
|
1683
1732
|
}
|
|
1684
1733
|
}
|
|
1685
1734
|
}
|
|
1686
|
-
const shouldUseFallbackVisibleAnchor = dataChanged && mvcpData && scrollTarget === void 0 && (
|
|
1735
|
+
const shouldUseFallbackVisibleAnchor = dataChanged && mvcpData && scrollTarget === void 0 && (() => {
|
|
1736
|
+
if (targetId === void 0 || skipTargetAnchor) {
|
|
1737
|
+
return true;
|
|
1738
|
+
}
|
|
1739
|
+
const targetIndex = indexByKey.get(targetId);
|
|
1740
|
+
return targetIndex === void 0 || positions[targetIndex] === void 0;
|
|
1741
|
+
})();
|
|
1687
1742
|
if (shouldUseFallbackVisibleAnchor) {
|
|
1688
1743
|
for (let i = 0; i < idsInViewWithPositions.length; i++) {
|
|
1689
1744
|
const { id, position } = idsInViewWithPositions[i];
|
|
@@ -1694,7 +1749,7 @@ function prepareMVCP(ctx, dataChanged) {
|
|
|
1694
1749
|
continue;
|
|
1695
1750
|
}
|
|
1696
1751
|
}
|
|
1697
|
-
const newPosition = positions
|
|
1752
|
+
const newPosition = index !== void 0 ? positions[index] : void 0;
|
|
1698
1753
|
if (newPosition !== void 0) {
|
|
1699
1754
|
positionDiff = newPosition - position;
|
|
1700
1755
|
anchorIdForLock = id;
|
|
@@ -1704,11 +1759,12 @@ function prepareMVCP(ctx, dataChanged) {
|
|
|
1704
1759
|
}
|
|
1705
1760
|
}
|
|
1706
1761
|
if (!skipTargetAnchor && targetId !== void 0 && prevPosition !== void 0) {
|
|
1707
|
-
const
|
|
1762
|
+
const targetIndex = indexByKey.get(targetId);
|
|
1763
|
+
const newPosition = targetIndex !== void 0 ? positions[targetIndex] : void 0;
|
|
1708
1764
|
if (newPosition !== void 0) {
|
|
1709
1765
|
const totalSize = getContentSize(ctx);
|
|
1710
1766
|
let diff = newPosition - prevPosition;
|
|
1711
|
-
if (diff !== 0 && state.scroll + state.scrollLength > totalSize) {
|
|
1767
|
+
if (diff !== 0 && isEndAnchoredScrollTarget && state.scroll + state.scrollLength > totalSize) {
|
|
1712
1768
|
if (diff > 0) {
|
|
1713
1769
|
diff = Math.max(0, totalSize - state.scroll - state.scrollLength);
|
|
1714
1770
|
} else {
|
|
@@ -1751,17 +1807,15 @@ function prepareColumnStartState(ctx, startIndex, useAverageSize) {
|
|
|
1751
1807
|
const state = ctx.state;
|
|
1752
1808
|
const numColumns = peek$(ctx, "numColumns");
|
|
1753
1809
|
let rowStartIndex = startIndex;
|
|
1754
|
-
const columnAtStart = state.columns
|
|
1810
|
+
const columnAtStart = state.columns[startIndex];
|
|
1755
1811
|
if (columnAtStart !== 1) {
|
|
1756
1812
|
rowStartIndex = findRowStartIndex(state, numColumns, startIndex);
|
|
1757
1813
|
}
|
|
1758
1814
|
let currentRowTop = 0;
|
|
1759
|
-
const
|
|
1760
|
-
const column = state.columns.get(curId);
|
|
1815
|
+
const column = state.columns[rowStartIndex];
|
|
1761
1816
|
if (rowStartIndex > 0) {
|
|
1762
1817
|
const prevIndex = rowStartIndex - 1;
|
|
1763
|
-
const
|
|
1764
|
-
const prevPosition = (_a3 = state.positions.get(prevId)) != null ? _a3 : 0;
|
|
1818
|
+
const prevPosition = (_a3 = state.positions[prevIndex]) != null ? _a3 : 0;
|
|
1765
1819
|
const prevRowStart = findRowStartIndex(state, numColumns, prevIndex);
|
|
1766
1820
|
const prevRowHeight = calculateRowMaxSize(ctx, prevRowStart, prevIndex, useAverageSize);
|
|
1767
1821
|
currentRowTop = prevPosition + prevRowHeight;
|
|
@@ -1778,7 +1832,7 @@ function findRowStartIndex(state, numColumns, index) {
|
|
|
1778
1832
|
}
|
|
1779
1833
|
let rowStart = Math.max(0, index);
|
|
1780
1834
|
while (rowStart > 0) {
|
|
1781
|
-
const columnForIndex = state.columns
|
|
1835
|
+
const columnForIndex = state.columns[rowStart];
|
|
1782
1836
|
if (columnForIndex === 1) {
|
|
1783
1837
|
break;
|
|
1784
1838
|
}
|
|
@@ -1811,7 +1865,7 @@ function calculateRowMaxSize(ctx, startIndex, endIndex, useAverageSize) {
|
|
|
1811
1865
|
|
|
1812
1866
|
// src/core/updateTotalSize.ts
|
|
1813
1867
|
function updateTotalSize(ctx) {
|
|
1814
|
-
var _a3, _b
|
|
1868
|
+
var _a3, _b;
|
|
1815
1869
|
const state = ctx.state;
|
|
1816
1870
|
const {
|
|
1817
1871
|
positions,
|
|
@@ -1821,36 +1875,34 @@ function updateTotalSize(ctx) {
|
|
|
1821
1875
|
if (data.length === 0) {
|
|
1822
1876
|
addTotalSize(ctx, null, 0);
|
|
1823
1877
|
} else {
|
|
1824
|
-
const
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
break;
|
|
1835
|
-
}
|
|
1836
|
-
rowStart -= 1;
|
|
1837
|
-
}
|
|
1838
|
-
let maxSize = 0;
|
|
1839
|
-
for (let i = rowStart; i < data.length; i++) {
|
|
1840
|
-
const rowId = (_c = state.idCache[i]) != null ? _c : getId(state, i);
|
|
1841
|
-
const size = getItemSize(ctx, rowId, i, data[i]);
|
|
1842
|
-
if (size > maxSize) {
|
|
1843
|
-
maxSize = size;
|
|
1844
|
-
}
|
|
1878
|
+
const lastIndex = data.length - 1;
|
|
1879
|
+
const lastId = getId(state, lastIndex);
|
|
1880
|
+
const lastPosition = positions[lastIndex];
|
|
1881
|
+
if (lastId !== void 0 && lastPosition !== void 0) {
|
|
1882
|
+
if (numColumns > 1) {
|
|
1883
|
+
let rowStart = lastIndex;
|
|
1884
|
+
while (rowStart > 0) {
|
|
1885
|
+
const column = state.columns[rowStart];
|
|
1886
|
+
if (column === 1 || column === void 0) {
|
|
1887
|
+
break;
|
|
1845
1888
|
}
|
|
1846
|
-
|
|
1847
|
-
}
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1889
|
+
rowStart -= 1;
|
|
1890
|
+
}
|
|
1891
|
+
let maxSize = 0;
|
|
1892
|
+
for (let i = rowStart; i <= lastIndex; i++) {
|
|
1893
|
+
const rowId = (_b = state.idCache[i]) != null ? _b : getId(state, i);
|
|
1894
|
+
const size = getItemSize(ctx, rowId, i, data[i]);
|
|
1895
|
+
if (size > maxSize) {
|
|
1896
|
+
maxSize = size;
|
|
1852
1897
|
}
|
|
1853
1898
|
}
|
|
1899
|
+
addTotalSize(ctx, null, lastPosition + maxSize);
|
|
1900
|
+
} else {
|
|
1901
|
+
const lastSize = getItemSize(ctx, lastId, lastIndex, data[lastIndex]);
|
|
1902
|
+
if (lastSize !== void 0) {
|
|
1903
|
+
const totalSize = lastPosition + lastSize;
|
|
1904
|
+
addTotalSize(ctx, null, totalSize);
|
|
1905
|
+
}
|
|
1854
1906
|
}
|
|
1855
1907
|
}
|
|
1856
1908
|
}
|
|
@@ -1899,14 +1951,13 @@ var getScrollVelocity = (state) => {
|
|
|
1899
1951
|
function updateSnapToOffsets(ctx) {
|
|
1900
1952
|
const state = ctx.state;
|
|
1901
1953
|
const {
|
|
1902
|
-
positions,
|
|
1903
1954
|
props: { snapToIndices }
|
|
1904
1955
|
} = state;
|
|
1905
1956
|
const snapToOffsets = Array(snapToIndices.length);
|
|
1906
1957
|
for (let i = 0; i < snapToIndices.length; i++) {
|
|
1907
1958
|
const idx = snapToIndices[i];
|
|
1908
|
-
|
|
1909
|
-
snapToOffsets[i] = positions
|
|
1959
|
+
getId(state, idx);
|
|
1960
|
+
snapToOffsets[i] = state.positions[idx];
|
|
1910
1961
|
}
|
|
1911
1962
|
set$(ctx, "snapToOffsets", snapToOffsets);
|
|
1912
1963
|
}
|
|
@@ -1918,8 +1969,9 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
|
|
|
1918
1969
|
scrollBottomBuffered: -1,
|
|
1919
1970
|
startIndex: 0
|
|
1920
1971
|
}) {
|
|
1921
|
-
var _a3, _b, _c, _d, _e
|
|
1972
|
+
var _a3, _b, _c, _d, _e;
|
|
1922
1973
|
const state = ctx.state;
|
|
1974
|
+
const hasPositionListeners = ctx.positionListeners.size > 0;
|
|
1923
1975
|
const {
|
|
1924
1976
|
columns,
|
|
1925
1977
|
columnSpans,
|
|
@@ -1946,7 +1998,15 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
|
|
|
1946
1998
|
let column = 1;
|
|
1947
1999
|
let maxSizeInRow = 0;
|
|
1948
2000
|
if (dataChanged) {
|
|
1949
|
-
columnSpans.
|
|
2001
|
+
columnSpans.length = 0;
|
|
2002
|
+
}
|
|
2003
|
+
if (!hasColumns) {
|
|
2004
|
+
if (columns.length) {
|
|
2005
|
+
columns.length = 0;
|
|
2006
|
+
}
|
|
2007
|
+
if (columnSpans.length) {
|
|
2008
|
+
columnSpans.length = 0;
|
|
2009
|
+
}
|
|
1950
2010
|
}
|
|
1951
2011
|
if (startIndex > 0) {
|
|
1952
2012
|
if (hasColumns) {
|
|
@@ -1960,12 +2020,13 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
|
|
|
1960
2020
|
} else if (startIndex < dataLength) {
|
|
1961
2021
|
const prevIndex = startIndex - 1;
|
|
1962
2022
|
const prevId = getId(state, prevIndex);
|
|
1963
|
-
const prevPosition = (_c = positions
|
|
2023
|
+
const prevPosition = (_c = positions[prevIndex]) != null ? _c : 0;
|
|
1964
2024
|
const prevSize = (_d = sizesKnown.get(prevId)) != null ? _d : getItemSize(ctx, prevId, prevIndex, data[prevIndex], useAverageSize, preferCachedSize);
|
|
1965
2025
|
currentRowTop = prevPosition + prevSize;
|
|
1966
2026
|
}
|
|
1967
2027
|
}
|
|
1968
2028
|
const needsIndexByKey = dataChanged || indexByKey.size === 0;
|
|
2029
|
+
const canOverrideSpan = hasColumns && !!overrideItemLayout && !!layoutConfig;
|
|
1969
2030
|
let didBreakEarly = false;
|
|
1970
2031
|
let breakAt;
|
|
1971
2032
|
for (let i = startIndex; i < dataLength; i++) {
|
|
@@ -1979,7 +2040,7 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
|
|
|
1979
2040
|
}
|
|
1980
2041
|
const id = (_e = idCache[i]) != null ? _e : getId(state, i);
|
|
1981
2042
|
let span = 1;
|
|
1982
|
-
if (
|
|
2043
|
+
if (canOverrideSpan) {
|
|
1983
2044
|
layoutConfig.span = 1;
|
|
1984
2045
|
overrideItemLayout(layoutConfig, data[i], i, numColumns, extraData);
|
|
1985
2046
|
const requestedSpan = layoutConfig.span;
|
|
@@ -1992,7 +2053,8 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
|
|
|
1992
2053
|
column = 1;
|
|
1993
2054
|
maxSizeInRow = 0;
|
|
1994
2055
|
}
|
|
1995
|
-
const
|
|
2056
|
+
const knownSize = sizesKnown.get(id);
|
|
2057
|
+
const size = knownSize !== void 0 ? knownSize : getItemSize(ctx, id, i, data[i], useAverageSize, preferCachedSize);
|
|
1996
2058
|
if (IS_DEV && needsIndexByKey) {
|
|
1997
2059
|
if (indexByKeyForChecking.has(id)) {
|
|
1998
2060
|
console.error(
|
|
@@ -2001,16 +2063,20 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
|
|
|
2001
2063
|
}
|
|
2002
2064
|
indexByKeyForChecking.set(id, i);
|
|
2003
2065
|
}
|
|
2004
|
-
if (currentRowTop !== positions
|
|
2005
|
-
positions
|
|
2006
|
-
|
|
2066
|
+
if (currentRowTop !== positions[i]) {
|
|
2067
|
+
positions[i] = currentRowTop;
|
|
2068
|
+
if (hasPositionListeners) {
|
|
2069
|
+
notifyPosition$(ctx, id, currentRowTop);
|
|
2070
|
+
}
|
|
2007
2071
|
}
|
|
2008
2072
|
if (needsIndexByKey) {
|
|
2009
2073
|
indexByKey.set(id, i);
|
|
2010
2074
|
}
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2075
|
+
if (!hasColumns) {
|
|
2076
|
+
currentRowTop += size;
|
|
2077
|
+
} else {
|
|
2078
|
+
columns[i] = column;
|
|
2079
|
+
columnSpans[i] = span;
|
|
2014
2080
|
if (size > maxSizeInRow) {
|
|
2015
2081
|
maxSizeInRow = size;
|
|
2016
2082
|
}
|
|
@@ -2020,8 +2086,6 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
|
|
|
2020
2086
|
column = 1;
|
|
2021
2087
|
maxSizeInRow = 0;
|
|
2022
2088
|
}
|
|
2023
|
-
} else {
|
|
2024
|
-
currentRowTop += size;
|
|
2025
2089
|
}
|
|
2026
2090
|
}
|
|
2027
2091
|
if (!didBreakEarly) {
|
|
@@ -2173,14 +2237,38 @@ function shallowEqual(prev, next) {
|
|
|
2173
2237
|
return true;
|
|
2174
2238
|
}
|
|
2175
2239
|
function computeViewability(state, ctx, viewabilityConfig, containerId, key, scrollSize, item, index) {
|
|
2176
|
-
const { sizes,
|
|
2240
|
+
const { sizes, scroll: scrollState } = state;
|
|
2177
2241
|
const topPad = (peek$(ctx, "stylePaddingTop") || 0) + (peek$(ctx, "headerSize") || 0);
|
|
2178
2242
|
const { itemVisiblePercentThreshold, viewAreaCoveragePercentThreshold } = viewabilityConfig;
|
|
2179
2243
|
const viewAreaMode = viewAreaCoveragePercentThreshold != null;
|
|
2180
2244
|
const viewablePercentThreshold = viewAreaMode ? viewAreaCoveragePercentThreshold : itemVisiblePercentThreshold;
|
|
2181
2245
|
const scroll = scrollState - topPad;
|
|
2182
|
-
const
|
|
2246
|
+
const position = state.positions[index];
|
|
2183
2247
|
const size = sizes.get(key) || 0;
|
|
2248
|
+
if (position === void 0) {
|
|
2249
|
+
const value2 = {
|
|
2250
|
+
containerId,
|
|
2251
|
+
index,
|
|
2252
|
+
isViewable: false,
|
|
2253
|
+
item,
|
|
2254
|
+
key,
|
|
2255
|
+
percentOfScroller: 0,
|
|
2256
|
+
percentVisible: 0,
|
|
2257
|
+
scrollSize,
|
|
2258
|
+
size,
|
|
2259
|
+
sizeVisible: -1
|
|
2260
|
+
};
|
|
2261
|
+
const prev2 = ctx.mapViewabilityAmountValues.get(containerId);
|
|
2262
|
+
if (!shallowEqual(prev2, value2)) {
|
|
2263
|
+
ctx.mapViewabilityAmountValues.set(containerId, value2);
|
|
2264
|
+
const cb = ctx.mapViewabilityAmountCallbacks.get(containerId);
|
|
2265
|
+
if (cb) {
|
|
2266
|
+
cb(value2);
|
|
2267
|
+
}
|
|
2268
|
+
}
|
|
2269
|
+
return value2;
|
|
2270
|
+
}
|
|
2271
|
+
const top = position - scroll;
|
|
2184
2272
|
const bottom = top + size;
|
|
2185
2273
|
const isEntirelyVisible = top >= 0 && bottom <= scrollSize && bottom > top;
|
|
2186
2274
|
const sizeVisible = isEntirelyVisible ? size : Math.min(bottom, scrollSize) - Math.max(top, 0);
|
|
@@ -2393,37 +2481,24 @@ function scrollToIndex(ctx, { index, viewOffset = 0, animated = true, viewPositi
|
|
|
2393
2481
|
// src/utils/setDidLayout.ts
|
|
2394
2482
|
function setDidLayout(ctx) {
|
|
2395
2483
|
const state = ctx.state;
|
|
2396
|
-
const {
|
|
2397
|
-
loadStartTime,
|
|
2398
|
-
initialScroll,
|
|
2399
|
-
props: { onLoad }
|
|
2400
|
-
} = state;
|
|
2484
|
+
const { initialScroll } = state;
|
|
2401
2485
|
state.queuedInitialLayout = true;
|
|
2402
2486
|
checkAtBottom(ctx);
|
|
2403
|
-
const setIt = () => {
|
|
2404
|
-
setInitialRenderState(ctx, { didLayout: true });
|
|
2405
|
-
if (onLoad) {
|
|
2406
|
-
onLoad({ elapsedTimeInMs: Date.now() - loadStartTime });
|
|
2407
|
-
}
|
|
2408
|
-
};
|
|
2409
2487
|
if ((initialScroll == null ? void 0 : initialScroll.index) !== void 0) {
|
|
2410
2488
|
const target = initialScroll;
|
|
2411
2489
|
const runScroll = () => scrollToIndex(ctx, { ...target, animated: false });
|
|
2412
2490
|
runScroll();
|
|
2413
2491
|
requestAnimationFrame(runScroll);
|
|
2414
2492
|
}
|
|
2415
|
-
|
|
2493
|
+
setInitialRenderState(ctx, { didLayout: true });
|
|
2416
2494
|
}
|
|
2417
2495
|
|
|
2418
2496
|
// src/core/calculateItemsInView.ts
|
|
2419
2497
|
function findCurrentStickyIndex(stickyArray, scroll, state) {
|
|
2420
|
-
var _a3;
|
|
2421
|
-
const idCache = state.idCache;
|
|
2422
2498
|
const positions = state.positions;
|
|
2423
2499
|
for (let i = stickyArray.length - 1; i >= 0; i--) {
|
|
2424
2500
|
const stickyIndex = stickyArray[i];
|
|
2425
|
-
const
|
|
2426
|
-
const stickyPos = stickyId ? positions.get(stickyId) : void 0;
|
|
2501
|
+
const stickyPos = positions[stickyIndex];
|
|
2427
2502
|
if (stickyPos !== void 0 && scroll >= stickyPos) {
|
|
2428
2503
|
return i;
|
|
2429
2504
|
}
|
|
@@ -2453,7 +2528,7 @@ function handleStickyActivation(ctx, stickyHeaderIndices, stickyArray, currentSt
|
|
|
2453
2528
|
}
|
|
2454
2529
|
}
|
|
2455
2530
|
function handleStickyRecycling(ctx, stickyArray, scroll, drawDistance, currentStickyIdx, pendingRemoval, alwaysRenderIndicesSet) {
|
|
2456
|
-
var _a3, _b
|
|
2531
|
+
var _a3, _b;
|
|
2457
2532
|
const state = ctx.state;
|
|
2458
2533
|
for (const containerIndex of state.stickyContainerPool) {
|
|
2459
2534
|
const itemKey = peek$(ctx, `containerItemKey${containerIndex}`);
|
|
@@ -2471,14 +2546,13 @@ function handleStickyRecycling(ctx, stickyArray, scroll, drawDistance, currentSt
|
|
|
2471
2546
|
const nextIndex = stickyArray[arrayIdx + 1];
|
|
2472
2547
|
let shouldRecycle = false;
|
|
2473
2548
|
if (nextIndex) {
|
|
2474
|
-
const
|
|
2475
|
-
const nextPos = nextId ? state.positions.get(nextId) : void 0;
|
|
2549
|
+
const nextPos = state.positions[nextIndex];
|
|
2476
2550
|
shouldRecycle = nextPos !== void 0 && scroll > nextPos + drawDistance * 2;
|
|
2477
2551
|
} else {
|
|
2478
|
-
const currentId = (
|
|
2552
|
+
const currentId = (_a3 = state.idCache[itemIndex]) != null ? _a3 : getId(state, itemIndex);
|
|
2479
2553
|
if (currentId) {
|
|
2480
|
-
const currentPos = state.positions
|
|
2481
|
-
const currentSize = (
|
|
2554
|
+
const currentPos = state.positions[itemIndex];
|
|
2555
|
+
const currentSize = (_b = state.sizes.get(currentId)) != null ? _b : getItemSize(ctx, currentId, itemIndex, state.props.data[itemIndex]);
|
|
2482
2556
|
shouldRecycle = currentPos !== void 0 && scroll > currentPos + currentSize + drawDistance * 3;
|
|
2483
2557
|
}
|
|
2484
2558
|
}
|
|
@@ -2490,7 +2564,7 @@ function handleStickyRecycling(ctx, stickyArray, scroll, drawDistance, currentSt
|
|
|
2490
2564
|
function calculateItemsInView(ctx, params = {}) {
|
|
2491
2565
|
const state = ctx.state;
|
|
2492
2566
|
reactNative.unstable_batchedUpdates(() => {
|
|
2493
|
-
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k
|
|
2567
|
+
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2494
2568
|
const {
|
|
2495
2569
|
columns,
|
|
2496
2570
|
columnSpans,
|
|
@@ -2585,7 +2659,9 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
2585
2659
|
if (dataChanged) {
|
|
2586
2660
|
indexByKey.clear();
|
|
2587
2661
|
idCache.length = 0;
|
|
2588
|
-
positions.
|
|
2662
|
+
positions.length = 0;
|
|
2663
|
+
columns.length = 0;
|
|
2664
|
+
columnSpans.length = 0;
|
|
2589
2665
|
}
|
|
2590
2666
|
const startIndex = forceFullItemPositions || dataChanged ? 0 : (_b = minIndexSizeChanged != null ? minIndexSizeChanged : state.startBuffered) != null ? _b : 0;
|
|
2591
2667
|
updateItemPositions(ctx, dataChanged, {
|
|
@@ -2606,7 +2682,7 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
2606
2682
|
let loopStart = !dataChanged && startBufferedIdOrig ? indexByKey.get(startBufferedIdOrig) || 0 : 0;
|
|
2607
2683
|
for (let i = loopStart; i >= 0; i--) {
|
|
2608
2684
|
const id = (_c = idCache[i]) != null ? _c : getId(state, i);
|
|
2609
|
-
const top = positions
|
|
2685
|
+
const top = positions[i];
|
|
2610
2686
|
const size = (_d = sizes.get(id)) != null ? _d : getItemSize(ctx, id, i, data[i]);
|
|
2611
2687
|
const bottom = top + size;
|
|
2612
2688
|
if (bottom > scroll - scrollBufferTop) {
|
|
@@ -2617,8 +2693,7 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
2617
2693
|
}
|
|
2618
2694
|
if (numColumns > 1) {
|
|
2619
2695
|
while (loopStart > 0) {
|
|
2620
|
-
const
|
|
2621
|
-
const loopColumn = columns.get(loopId);
|
|
2696
|
+
const loopColumn = columns[loopStart];
|
|
2622
2697
|
if (loopColumn === 1 || loopColumn === void 0) {
|
|
2623
2698
|
break;
|
|
2624
2699
|
}
|
|
@@ -2639,9 +2714,9 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
2639
2714
|
let firstFullyOnScreenIndex;
|
|
2640
2715
|
const dataLength = data.length;
|
|
2641
2716
|
for (let i = Math.max(0, loopStart); i < dataLength && (!foundEnd || i <= maxIndexRendered); i++) {
|
|
2642
|
-
const id = (
|
|
2643
|
-
const size = (
|
|
2644
|
-
const top = positions
|
|
2717
|
+
const id = (_e = idCache[i]) != null ? _e : getId(state, i);
|
|
2718
|
+
const size = (_f = sizes.get(id)) != null ? _f : getItemSize(ctx, id, i, data[i]);
|
|
2719
|
+
const top = positions[i];
|
|
2645
2720
|
if (!foundEnd) {
|
|
2646
2721
|
if (startNoBuffer === null && top + size > scroll) {
|
|
2647
2722
|
startNoBuffer = i;
|
|
@@ -2677,7 +2752,7 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
2677
2752
|
}
|
|
2678
2753
|
const idsInView = [];
|
|
2679
2754
|
for (let i = firstFullyOnScreenIndex; i <= endNoBuffer; i++) {
|
|
2680
|
-
const id = (
|
|
2755
|
+
const id = (_g = idCache[i]) != null ? _g : getId(state, i);
|
|
2681
2756
|
idsInView.push(id);
|
|
2682
2757
|
}
|
|
2683
2758
|
Object.assign(state, {
|
|
@@ -2709,7 +2784,7 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
2709
2784
|
const needNewContainers = [];
|
|
2710
2785
|
const needNewContainersSet = /* @__PURE__ */ new Set();
|
|
2711
2786
|
for (let i = startBuffered; i <= endBuffered; i++) {
|
|
2712
|
-
const id = (
|
|
2787
|
+
const id = (_h = idCache[i]) != null ? _h : getId(state, i);
|
|
2713
2788
|
if (!containerItemKeys.has(id)) {
|
|
2714
2789
|
needNewContainersSet.add(i);
|
|
2715
2790
|
needNewContainers.push(i);
|
|
@@ -2718,7 +2793,7 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
2718
2793
|
if (alwaysRenderArr.length > 0) {
|
|
2719
2794
|
for (const index of alwaysRenderArr) {
|
|
2720
2795
|
if (index < 0 || index >= dataLength) continue;
|
|
2721
|
-
const id = (
|
|
2796
|
+
const id = (_i = idCache[index]) != null ? _i : getId(state, index);
|
|
2722
2797
|
if (id && !containerItemKeys.has(id) && !needNewContainersSet.has(index)) {
|
|
2723
2798
|
needNewContainersSet.add(index);
|
|
2724
2799
|
needNewContainers.push(index);
|
|
@@ -2756,7 +2831,7 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
2756
2831
|
for (let idx = 0; idx < needNewContainers.length; idx++) {
|
|
2757
2832
|
const i = needNewContainers[idx];
|
|
2758
2833
|
const containerIndex = availableContainers[idx];
|
|
2759
|
-
const id = (
|
|
2834
|
+
const id = (_j = idCache[i]) != null ? _j : getId(state, i);
|
|
2760
2835
|
const oldKey = peek$(ctx, `containerItemKey${containerIndex}`);
|
|
2761
2836
|
if (oldKey && oldKey !== id) {
|
|
2762
2837
|
containerItemKeys.delete(oldKey);
|
|
@@ -2797,7 +2872,7 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
2797
2872
|
if (alwaysRenderArr.length > 0) {
|
|
2798
2873
|
for (const index of alwaysRenderArr) {
|
|
2799
2874
|
if (index < 0 || index >= dataLength) continue;
|
|
2800
|
-
const id = (
|
|
2875
|
+
const id = (_k = idCache[index]) != null ? _k : getId(state, index);
|
|
2801
2876
|
const containerIndex = containerItemKeys.get(id);
|
|
2802
2877
|
if (containerIndex !== void 0) {
|
|
2803
2878
|
state.stickyContainerPool.add(containerIndex);
|
|
@@ -2837,14 +2912,13 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
2837
2912
|
const itemIndex = indexByKey.get(itemKey);
|
|
2838
2913
|
const item = data[itemIndex];
|
|
2839
2914
|
if (item !== void 0) {
|
|
2840
|
-
const
|
|
2841
|
-
const positionValue = positions.get(id);
|
|
2915
|
+
const positionValue = positions[itemIndex];
|
|
2842
2916
|
if (positionValue === void 0) {
|
|
2843
2917
|
set$(ctx, `containerPosition${i}`, POSITION_OUT_OF_VIEW);
|
|
2844
2918
|
} else {
|
|
2845
2919
|
const position = (positionValue || 0) - scrollAdjustPending;
|
|
2846
|
-
const column = columns
|
|
2847
|
-
const span = columnSpans
|
|
2920
|
+
const column = columns[itemIndex] || 1;
|
|
2921
|
+
const span = columnSpans[itemIndex] || 1;
|
|
2848
2922
|
const prevPos = peek$(ctx, `containerPosition${i}`);
|
|
2849
2923
|
const prevColumn = peek$(ctx, `containerColumn${i}`);
|
|
2850
2924
|
const prevSpan = peek$(ctx, `containerSpan${i}`);
|
|
@@ -3137,7 +3211,7 @@ function onScroll(ctx, event) {
|
|
|
3137
3211
|
}
|
|
3138
3212
|
let newScroll = event.nativeEvent.contentOffset[state.props.horizontal ? "x" : "y"];
|
|
3139
3213
|
if (state.scrollingTo && state.scrollingTo.offset >= newScroll) {
|
|
3140
|
-
const maxOffset = clampScrollOffset(ctx, newScroll);
|
|
3214
|
+
const maxOffset = clampScrollOffset(ctx, newScroll, state.scrollingTo);
|
|
3141
3215
|
if (newScroll !== maxOffset && Math.abs(newScroll - maxOffset) > 1) {
|
|
3142
3216
|
newScroll = maxOffset;
|
|
3143
3217
|
scrollTo(ctx, {
|
|
@@ -3190,7 +3264,7 @@ var ScrollAdjustHandler = class {
|
|
|
3190
3264
|
if ((scrollTarget == null ? void 0 : scrollTarget.index) !== void 0) {
|
|
3191
3265
|
const currentOffset = calculateOffsetForIndex(this.ctx, scrollTarget.index);
|
|
3192
3266
|
targetScroll = calculateOffsetWithOffsetPosition(this.ctx, currentOffset, scrollTarget);
|
|
3193
|
-
targetScroll = clampScrollOffset(this.ctx, targetScroll);
|
|
3267
|
+
targetScroll = clampScrollOffset(this.ctx, targetScroll, scrollTarget);
|
|
3194
3268
|
} else {
|
|
3195
3269
|
targetScroll = clampScrollOffset(this.ctx, state.scroll + pending);
|
|
3196
3270
|
}
|
|
@@ -3391,8 +3465,9 @@ function getWindowSize() {
|
|
|
3391
3465
|
}
|
|
3392
3466
|
var StyleSheet = reactNative.StyleSheet;
|
|
3393
3467
|
function useStickyScrollHandler(stickyHeaderIndices, horizontal, ctx, onScroll2) {
|
|
3468
|
+
const shouldUseRnAnimatedEngine = !ctx.state.props.stickyPositionComponentInternal;
|
|
3394
3469
|
return React2.useMemo(() => {
|
|
3395
|
-
if (stickyHeaderIndices == null ? void 0 : stickyHeaderIndices.length) {
|
|
3470
|
+
if ((stickyHeaderIndices == null ? void 0 : stickyHeaderIndices.length) && shouldUseRnAnimatedEngine) {
|
|
3396
3471
|
const { animatedScrollY } = ctx;
|
|
3397
3472
|
return reactNative.Animated.event(
|
|
3398
3473
|
[
|
|
@@ -3409,7 +3484,7 @@ function useStickyScrollHandler(stickyHeaderIndices, horizontal, ctx, onScroll2)
|
|
|
3409
3484
|
);
|
|
3410
3485
|
}
|
|
3411
3486
|
return onScroll2;
|
|
3412
|
-
}, [stickyHeaderIndices == null ? void 0 : stickyHeaderIndices.join(","), horizontal]);
|
|
3487
|
+
}, [stickyHeaderIndices == null ? void 0 : stickyHeaderIndices.join(","), horizontal, shouldUseRnAnimatedEngine]);
|
|
3413
3488
|
}
|
|
3414
3489
|
|
|
3415
3490
|
// src/utils/createColumnWrapperStyle.ts
|
|
@@ -3430,6 +3505,18 @@ function createColumnWrapperStyle(contentContainerStyle) {
|
|
|
3430
3505
|
// src/utils/createImperativeHandle.ts
|
|
3431
3506
|
function createImperativeHandle(ctx) {
|
|
3432
3507
|
const state = ctx.state;
|
|
3508
|
+
const runScrollWithPromise = (run) => new Promise((resolve) => {
|
|
3509
|
+
var _a3;
|
|
3510
|
+
(_a3 = state.pendingScrollResolve) == null ? void 0 : _a3.call(state);
|
|
3511
|
+
state.pendingScrollResolve = resolve;
|
|
3512
|
+
const didStartScroll = run();
|
|
3513
|
+
if (!didStartScroll || !state.scrollingTo) {
|
|
3514
|
+
if (state.pendingScrollResolve === resolve) {
|
|
3515
|
+
state.pendingScrollResolve = void 0;
|
|
3516
|
+
}
|
|
3517
|
+
resolve();
|
|
3518
|
+
}
|
|
3519
|
+
});
|
|
3433
3520
|
const scrollIndexIntoView = (options) => {
|
|
3434
3521
|
if (state) {
|
|
3435
3522
|
const { index, ...rest } = options;
|
|
@@ -3441,11 +3528,36 @@ function createImperativeHandle(ctx) {
|
|
|
3441
3528
|
index,
|
|
3442
3529
|
viewPosition
|
|
3443
3530
|
});
|
|
3531
|
+
return true;
|
|
3444
3532
|
}
|
|
3445
3533
|
}
|
|
3534
|
+
return false;
|
|
3446
3535
|
};
|
|
3447
3536
|
const refScroller = state.refScroller;
|
|
3537
|
+
const clearCaches = (options) => {
|
|
3538
|
+
var _a3, _b;
|
|
3539
|
+
const mode = (_a3 = options == null ? void 0 : options.mode) != null ? _a3 : "sizes";
|
|
3540
|
+
state.sizes.clear();
|
|
3541
|
+
state.sizesKnown.clear();
|
|
3542
|
+
for (const key in state.averageSizes) {
|
|
3543
|
+
delete state.averageSizes[key];
|
|
3544
|
+
}
|
|
3545
|
+
state.minIndexSizeChanged = 0;
|
|
3546
|
+
state.scrollForNextCalculateItemsInView = void 0;
|
|
3547
|
+
state.pendingTotalSize = void 0;
|
|
3548
|
+
state.totalSize = 0;
|
|
3549
|
+
set$(ctx, "totalSize", 0);
|
|
3550
|
+
if (mode === "full") {
|
|
3551
|
+
state.indexByKey.clear();
|
|
3552
|
+
state.idCache.length = 0;
|
|
3553
|
+
state.positions.length = 0;
|
|
3554
|
+
state.columns.length = 0;
|
|
3555
|
+
state.columnSpans.length = 0;
|
|
3556
|
+
}
|
|
3557
|
+
(_b = state.triggerCalculateItemsInView) == null ? void 0 : _b.call(state, { forceFullItemPositions: true });
|
|
3558
|
+
};
|
|
3448
3559
|
return {
|
|
3560
|
+
clearCaches,
|
|
3449
3561
|
flashScrollIndicators: () => refScroller.current.flashScrollIndicators(),
|
|
3450
3562
|
getNativeScrollRef: () => refScroller.current,
|
|
3451
3563
|
getScrollableNode: () => refScroller.current.getScrollableNode(),
|
|
@@ -3464,8 +3576,11 @@ function createImperativeHandle(ctx) {
|
|
|
3464
3576
|
isAtStart: state.isAtStart,
|
|
3465
3577
|
listen: (signalName, cb) => listen$(ctx, signalName, cb),
|
|
3466
3578
|
listenToPosition: (key, cb) => listenPosition$(ctx, key, cb),
|
|
3467
|
-
positionAtIndex: (index) => state.positions
|
|
3468
|
-
|
|
3579
|
+
positionAtIndex: (index) => state.positions[index],
|
|
3580
|
+
positionByKey: (key) => {
|
|
3581
|
+
const index = state.indexByKey.get(key);
|
|
3582
|
+
return index === void 0 ? void 0 : state.positions[index];
|
|
3583
|
+
},
|
|
3469
3584
|
scroll: state.scroll,
|
|
3470
3585
|
scrollLength: state.scrollLength,
|
|
3471
3586
|
scrollVelocity: getScrollVelocity(state),
|
|
@@ -3478,15 +3593,17 @@ function createImperativeHandle(ctx) {
|
|
|
3478
3593
|
state.contentInsetOverride = inset != null ? inset : void 0;
|
|
3479
3594
|
updateScroll(ctx, state.scroll, true);
|
|
3480
3595
|
},
|
|
3481
|
-
scrollIndexIntoView,
|
|
3482
|
-
scrollItemIntoView: ({ item, ...props }) => {
|
|
3596
|
+
scrollIndexIntoView: (options) => runScrollWithPromise(() => scrollIndexIntoView(options)),
|
|
3597
|
+
scrollItemIntoView: ({ item, ...props }) => runScrollWithPromise(() => {
|
|
3483
3598
|
const data = state.props.data;
|
|
3484
3599
|
const index = data.indexOf(item);
|
|
3485
3600
|
if (index !== -1) {
|
|
3486
3601
|
scrollIndexIntoView({ index, ...props });
|
|
3602
|
+
return true;
|
|
3487
3603
|
}
|
|
3488
|
-
|
|
3489
|
-
|
|
3604
|
+
return false;
|
|
3605
|
+
}),
|
|
3606
|
+
scrollToEnd: (options) => runScrollWithPromise(() => {
|
|
3490
3607
|
const data = state.props.data;
|
|
3491
3608
|
const stylePaddingBottom = state.props.stylePaddingBottom;
|
|
3492
3609
|
const index = data.length - 1;
|
|
@@ -3499,17 +3616,27 @@ function createImperativeHandle(ctx) {
|
|
|
3499
3616
|
viewOffset: -paddingBottom - footerSize + ((options == null ? void 0 : options.viewOffset) || 0),
|
|
3500
3617
|
viewPosition: 1
|
|
3501
3618
|
});
|
|
3619
|
+
return true;
|
|
3502
3620
|
}
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3621
|
+
return false;
|
|
3622
|
+
}),
|
|
3623
|
+
scrollToIndex: (params) => runScrollWithPromise(() => {
|
|
3624
|
+
scrollToIndex(ctx, params);
|
|
3625
|
+
return true;
|
|
3626
|
+
}),
|
|
3627
|
+
scrollToItem: ({ item, ...props }) => runScrollWithPromise(() => {
|
|
3506
3628
|
const data = state.props.data;
|
|
3507
3629
|
const index = data.indexOf(item);
|
|
3508
3630
|
if (index !== -1) {
|
|
3509
3631
|
scrollToIndex(ctx, { index, ...props });
|
|
3632
|
+
return true;
|
|
3510
3633
|
}
|
|
3511
|
-
|
|
3512
|
-
|
|
3634
|
+
return false;
|
|
3635
|
+
}),
|
|
3636
|
+
scrollToOffset: (params) => runScrollWithPromise(() => {
|
|
3637
|
+
scrollTo(ctx, params);
|
|
3638
|
+
return true;
|
|
3639
|
+
}),
|
|
3513
3640
|
setScrollProcessingEnabled: (enabled) => {
|
|
3514
3641
|
state.scrollProcessingEnabled = enabled;
|
|
3515
3642
|
},
|
|
@@ -3606,8 +3733,8 @@ function normalizeMaintainVisibleContentPosition(value) {
|
|
|
3606
3733
|
if (value && typeof value === "object") {
|
|
3607
3734
|
return {
|
|
3608
3735
|
data: (_a3 = value.data) != null ? _a3 : false,
|
|
3609
|
-
|
|
3610
|
-
|
|
3736
|
+
shouldRestorePosition: value.shouldRestorePosition,
|
|
3737
|
+
size: (_b = value.size) != null ? _b : true
|
|
3611
3738
|
};
|
|
3612
3739
|
}
|
|
3613
3740
|
if (value === false) {
|
|
@@ -3679,7 +3806,7 @@ function useThrottledOnScroll(originalHandler, scrollEventThrottle) {
|
|
|
3679
3806
|
}
|
|
3680
3807
|
|
|
3681
3808
|
// src/components/LegendList.tsx
|
|
3682
|
-
var LegendList =
|
|
3809
|
+
var LegendList = typedMemo2(
|
|
3683
3810
|
// biome-ignore lint/nursery/noShadow: const function name shadowing is intentional
|
|
3684
3811
|
typedForwardRef(function LegendList2(props, forwardedRef) {
|
|
3685
3812
|
const { children, data: dataProp, renderItem: renderItemProp, ...restProps } = props;
|
|
@@ -3746,6 +3873,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3746
3873
|
refreshControl,
|
|
3747
3874
|
refreshing,
|
|
3748
3875
|
refScrollView,
|
|
3876
|
+
renderScrollComponent,
|
|
3749
3877
|
renderItem,
|
|
3750
3878
|
scrollEventThrottle,
|
|
3751
3879
|
snapToIndices,
|
|
@@ -3754,13 +3882,21 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3754
3882
|
// TODOV3: Remove from v3 release
|
|
3755
3883
|
style: styleProp,
|
|
3756
3884
|
suggestEstimatedItemSize,
|
|
3885
|
+
useWindowScroll = false,
|
|
3757
3886
|
viewabilityConfig,
|
|
3758
3887
|
viewabilityConfigCallbackPairs,
|
|
3759
3888
|
waitForInitialLayout = true,
|
|
3760
3889
|
...rest
|
|
3761
3890
|
} = props;
|
|
3762
3891
|
const animatedPropsInternal = props.animatedPropsInternal;
|
|
3763
|
-
const
|
|
3892
|
+
const positionComponentInternal = props.positionComponentInternal;
|
|
3893
|
+
const stickyPositionComponentInternal = props.stickyPositionComponentInternal;
|
|
3894
|
+
const {
|
|
3895
|
+
childrenMode,
|
|
3896
|
+
positionComponentInternal: _positionComponentInternal,
|
|
3897
|
+
stickyPositionComponentInternal: _stickyPositionComponentInternal,
|
|
3898
|
+
...restProps
|
|
3899
|
+
} = rest;
|
|
3764
3900
|
const contentContainerStyleBase = StyleSheet.flatten(contentContainerStyleProp);
|
|
3765
3901
|
const shouldFlexGrow = alignItemsAtEnd && (horizontal ? (contentContainerStyleBase == null ? void 0 : contentContainerStyleBase.minWidth) == null : (contentContainerStyleBase == null ? void 0 : contentContainerStyleBase.minHeight) == null);
|
|
3766
3902
|
const contentContainerStyle = {
|
|
@@ -3812,6 +3948,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3812
3948
|
"stickyIndices has been renamed to stickyHeaderIndices. Please update your props to use stickyHeaderIndices."
|
|
3813
3949
|
);
|
|
3814
3950
|
}
|
|
3951
|
+
if (IS_DEV && useWindowScroll && renderScrollComponent) {
|
|
3952
|
+
warnDevOnce(
|
|
3953
|
+
"useWindowScrollRenderScrollComponent",
|
|
3954
|
+
"useWindowScroll is not supported when renderScrollComponent is provided."
|
|
3955
|
+
);
|
|
3956
|
+
}
|
|
3957
|
+
const useWindowScrollResolved = Platform2.OS === "web" && !!useWindowScroll && !renderScrollComponent;
|
|
3815
3958
|
const refState = React2.useRef();
|
|
3816
3959
|
const hasOverrideItemLayout = !!overrideItemLayout;
|
|
3817
3960
|
const prevHasOverrideItemLayout = React2.useRef(hasOverrideItemLayout);
|
|
@@ -3821,11 +3964,12 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3821
3964
|
ctx.state = {
|
|
3822
3965
|
activeStickyIndex: -1,
|
|
3823
3966
|
averageSizes: {},
|
|
3824
|
-
columnSpans:
|
|
3825
|
-
columns:
|
|
3967
|
+
columnSpans: [],
|
|
3968
|
+
columns: [],
|
|
3826
3969
|
containerItemKeys: /* @__PURE__ */ new Map(),
|
|
3827
3970
|
containerItemTypes: /* @__PURE__ */ new Map(),
|
|
3828
3971
|
contentInsetOverride: void 0,
|
|
3972
|
+
dataChangeEpoch: 0,
|
|
3829
3973
|
dataChangeNeedsScrollUpdate: false,
|
|
3830
3974
|
didColumnsChange: false,
|
|
3831
3975
|
didDataChange: false,
|
|
@@ -3857,10 +4001,10 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3857
4001
|
minIndexSizeChanged: 0,
|
|
3858
4002
|
nativeContentInset: void 0,
|
|
3859
4003
|
nativeMarginTop: 0,
|
|
3860
|
-
positions:
|
|
4004
|
+
positions: [],
|
|
3861
4005
|
props: {},
|
|
3862
4006
|
queuedCalculateItemsInView: 0,
|
|
3863
|
-
refScroller:
|
|
4007
|
+
refScroller: { current: null },
|
|
3864
4008
|
scroll: 0,
|
|
3865
4009
|
scrollAdjustHandler: new ScrollAdjustHandler(ctx),
|
|
3866
4010
|
scrollForNextCalculateItemsInView: void 0,
|
|
@@ -3876,6 +4020,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3876
4020
|
startBuffered: -1,
|
|
3877
4021
|
startNoBuffer: -1,
|
|
3878
4022
|
startReachedSnapshot: void 0,
|
|
4023
|
+
startReachedSnapshotDataChangeEpoch: void 0,
|
|
3879
4024
|
stickyContainerPool: /* @__PURE__ */ new Set(),
|
|
3880
4025
|
stickyContainers: /* @__PURE__ */ new Map(),
|
|
3881
4026
|
timeoutSizeMessage: 0,
|
|
@@ -3895,6 +4040,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3895
4040
|
state.didColumnsChange = numColumnsProp !== state.props.numColumns;
|
|
3896
4041
|
const didDataChangeLocal = state.props.dataVersion !== dataVersion || state.props.data !== dataProp && checkActualChange(state, dataProp, state.props.data);
|
|
3897
4042
|
if (didDataChangeLocal) {
|
|
4043
|
+
state.dataChangeEpoch += 1;
|
|
3898
4044
|
state.dataChangeNeedsScrollUpdate = true;
|
|
3899
4045
|
state.didDataChange = true;
|
|
3900
4046
|
state.previousData = state.props.data;
|
|
@@ -3931,14 +4077,17 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3931
4077
|
onStartReachedThreshold,
|
|
3932
4078
|
onStickyHeaderChange,
|
|
3933
4079
|
overrideItemLayout,
|
|
4080
|
+
positionComponentInternal,
|
|
3934
4081
|
recycleItems: !!recycleItems,
|
|
3935
4082
|
renderItem,
|
|
3936
4083
|
snapToIndices,
|
|
3937
4084
|
stickyIndicesArr: stickyHeaderIndices != null ? stickyHeaderIndices : [],
|
|
3938
4085
|
stickyIndicesSet: React2.useMemo(() => new Set(stickyHeaderIndices != null ? stickyHeaderIndices : []), [stickyHeaderIndices == null ? void 0 : stickyHeaderIndices.join(",")]),
|
|
4086
|
+
stickyPositionComponentInternal,
|
|
3939
4087
|
stylePaddingBottom: stylePaddingBottomState,
|
|
3940
4088
|
stylePaddingTop: stylePaddingTopState,
|
|
3941
|
-
suggestEstimatedItemSize: !!suggestEstimatedItemSize
|
|
4089
|
+
suggestEstimatedItemSize: !!suggestEstimatedItemSize,
|
|
4090
|
+
useWindowScroll: useWindowScrollResolved
|
|
3942
4091
|
};
|
|
3943
4092
|
state.refScroller = refScroller;
|
|
3944
4093
|
const memoizedLastItemKeys = React2.useMemo(() => {
|
|
@@ -3989,7 +4138,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3989
4138
|
} else {
|
|
3990
4139
|
const baseOffset = initialScroll.index !== void 0 ? calculateOffsetForIndex(ctx, initialScroll.index) : 0;
|
|
3991
4140
|
const resolvedOffset = calculateOffsetWithOffsetPosition(ctx, baseOffset, initialScroll);
|
|
3992
|
-
const clampedOffset = clampScrollOffset(ctx, resolvedOffset);
|
|
4141
|
+
const clampedOffset = clampScrollOffset(ctx, resolvedOffset, initialScroll);
|
|
3993
4142
|
const updatedInitialScroll = { ...initialScroll, contentOffset: clampedOffset };
|
|
3994
4143
|
refState.current.initialScroll = updatedInitialScroll;
|
|
3995
4144
|
state.initialScroll = updatedInitialScroll;
|
|
@@ -4012,7 +4161,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
4012
4161
|
"Changing data without a keyExtractor can cause slow performance and resetting scroll. If your list data can change you should use a keyExtractor with a unique id for best performance and behavior."
|
|
4013
4162
|
);
|
|
4014
4163
|
refState.current.sizes.clear();
|
|
4015
|
-
refState.current.positions.
|
|
4164
|
+
refState.current.positions.length = 0;
|
|
4016
4165
|
refState.current.totalSize = 0;
|
|
4017
4166
|
set$(ctx, "totalSize", 0);
|
|
4018
4167
|
}
|
|
@@ -4145,7 +4294,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
4145
4294
|
return /* @__PURE__ */ React2__namespace.createElement(React2__namespace.Fragment, null, /* @__PURE__ */ React2__namespace.createElement(
|
|
4146
4295
|
ListComponent,
|
|
4147
4296
|
{
|
|
4148
|
-
...
|
|
4297
|
+
...restProps,
|
|
4149
4298
|
alignItemsAtEnd,
|
|
4150
4299
|
canRender,
|
|
4151
4300
|
contentContainerStyle,
|
|
@@ -4171,20 +4320,30 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
4171
4320
|
}
|
|
4172
4321
|
),
|
|
4173
4322
|
refScrollView: combinedRef,
|
|
4323
|
+
renderScrollComponent,
|
|
4174
4324
|
scrollAdjustHandler: (_d = refState.current) == null ? void 0 : _d.scrollAdjustHandler,
|
|
4175
4325
|
scrollEventThrottle: 0,
|
|
4176
4326
|
snapToIndices,
|
|
4177
4327
|
stickyHeaderIndices,
|
|
4178
4328
|
style,
|
|
4179
4329
|
updateItemSize: fns.updateItemSize,
|
|
4330
|
+
useWindowScroll: useWindowScrollResolved,
|
|
4180
4331
|
waitForInitialLayout
|
|
4181
4332
|
}
|
|
4182
4333
|
), IS_DEV && ENABLE_DEBUG_VIEW);
|
|
4183
4334
|
});
|
|
4184
4335
|
|
|
4185
|
-
|
|
4336
|
+
// src/index.ts
|
|
4337
|
+
var LegendList3 = LegendList;
|
|
4338
|
+
if (IS_DEV) {
|
|
4339
|
+
console.warn(
|
|
4340
|
+
"[legend-list] Legend List 3.0 deprecates the root import (@legendapp/list) because it now supports both react and react-native. The root import is fully functional, but please switch to platform-specific imports for strict platform types:\n - React Native: @legendapp/list/react-native\n - React: @legendapp/list/react\nSee README for details."
|
|
4341
|
+
);
|
|
4342
|
+
}
|
|
4343
|
+
|
|
4344
|
+
exports.LegendList = LegendList3;
|
|
4186
4345
|
exports.typedForwardRef = typedForwardRef;
|
|
4187
|
-
exports.typedMemo =
|
|
4346
|
+
exports.typedMemo = typedMemo2;
|
|
4188
4347
|
exports.useIsLastItem = useIsLastItem;
|
|
4189
4348
|
exports.useListScrollSize = useListScrollSize;
|
|
4190
4349
|
exports.useRecyclingEffect = useRecyclingEffect;
|