@legendapp/list 2.1.0-beta.1 → 2.1.0-beta.3

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.
Files changed (5) hide show
  1. package/index.d.mts +14 -13
  2. package/index.d.ts +14 -13
  3. package/index.js +302 -252
  4. package/index.mjs +302 -252
  5. package/package.json +1 -1
package/index.mjs CHANGED
@@ -33,7 +33,10 @@ function StateProvider({ children }) {
33
33
  ["stylePaddingTop", 0],
34
34
  ["headerSize", 0],
35
35
  ["numContainers", 0],
36
- ["totalSize", 0]
36
+ ["activeStickyIndex", void 0],
37
+ ["totalSize", 0],
38
+ ["scrollAdjustPending", 0],
39
+ ["scrollingTo", void 0]
37
40
  ]),
38
41
  viewRefs: /* @__PURE__ */ new Map()
39
42
  }));
@@ -196,8 +199,11 @@ var PositionViewState = typedMemo(function PositionView({
196
199
  ...rest
197
200
  }) {
198
201
  const [position = POSITION_OUT_OF_VIEW] = useArr$([`containerPosition${id}`]);
199
- const base = Array.isArray(style) ? Object.assign({}, ...style) : style;
200
- const combinedStyle = horizontal ? { ...base, left: position } : { ...base, top: position };
202
+ const base = {
203
+ contain: "paint layout style"
204
+ };
205
+ const composed = Array.isArray(style) ? Object.assign({}, ...style) : style;
206
+ const combinedStyle = horizontal ? { ...base, ...composed, left: position } : { ...base, ...composed, top: position };
201
207
  return /* @__PURE__ */ React3.createElement("div", { ref: refView, style: combinedStyle, ...rest });
202
208
  });
203
209
  var PositionViewSticky = typedMemo(function PositionViewSticky2({
@@ -206,19 +212,42 @@ var PositionViewSticky = typedMemo(function PositionViewSticky2({
206
212
  style,
207
213
  refView,
208
214
  index,
215
+ stickyOffset,
216
+ animatedScrollY: _animatedScrollY,
217
+ children,
209
218
  ...rest
210
219
  }) {
211
- const [position = POSITION_OUT_OF_VIEW, _headerSize] = useArr$([`containerPosition${id}`, "headerSize"]);
220
+ const [position = POSITION_OUT_OF_VIEW, headerSize = 0, activeStickyIndex] = useArr$([
221
+ `containerPosition${id}`,
222
+ "headerSize",
223
+ "activeStickyIndex"
224
+ ]);
225
+ const base = {
226
+ contain: "paint layout style"
227
+ };
228
+ const composed = React3.useMemo(
229
+ () => {
230
+ var _a3;
231
+ return (_a3 = Array.isArray(style) ? Object.assign({}, ...style) : style) != null ? _a3 : {};
232
+ },
233
+ [style]
234
+ );
212
235
  const viewStyle = React3.useMemo(() => {
213
- const base = Array.isArray(style) ? Object.assign({}, ...style) : style;
214
- const axisStyle = horizontal ? { transform: `translateX(${position}px)` } : { top: position };
215
- return {
216
- ...base,
217
- zIndex: index + 1e3,
218
- ...axisStyle
219
- };
220
- }, [style, position, horizontal, index]);
221
- return /* @__PURE__ */ React3.createElement("div", { ref: refView, style: viewStyle, ...rest });
236
+ var _a3;
237
+ const styleBase = { ...base, ...composed };
238
+ delete styleBase.transform;
239
+ const offset = (_a3 = stickyOffset != null ? stickyOffset : headerSize) != null ? _a3 : 0;
240
+ const isActive = activeStickyIndex === index;
241
+ styleBase.position = isActive ? "sticky" : "absolute";
242
+ styleBase.zIndex = index + 1e3;
243
+ if (horizontal) {
244
+ styleBase.left = isActive ? offset : position;
245
+ } else {
246
+ styleBase.top = isActive ? offset : position;
247
+ }
248
+ return styleBase;
249
+ }, [composed, horizontal, position, index, stickyOffset, headerSize, activeStickyIndex]);
250
+ return /* @__PURE__ */ React3.createElement("div", { ref: refView, style: viewStyle, ...rest }, children);
222
251
  });
223
252
  var PositionView2 = PositionViewState;
224
253
 
@@ -970,10 +999,11 @@ function PaddingDevMode() {
970
999
  function useValueListener$(key, callback) {
971
1000
  const ctx = useStateContext();
972
1001
  useLayoutEffect(() => {
973
- listen$(ctx, key, (value) => {
1002
+ const unsubscribe = listen$(ctx, key, (value) => {
974
1003
  callback(value);
975
1004
  });
976
- }, []);
1005
+ return unsubscribe;
1006
+ }, [callback, ctx, key]);
977
1007
  }
978
1008
 
979
1009
  // src/components/ScrollAdjust.tsx
@@ -1139,12 +1169,11 @@ function calculateOffsetForIndex(ctx, state, index) {
1139
1169
  }
1140
1170
 
1141
1171
  // src/utils/getItemSize.ts
1142
- function getItemSize(state, key, index, data, useAverageSize) {
1172
+ function getItemSize(ctx, state, key, index, data, useAverageSize) {
1143
1173
  var _a3, _b;
1144
1174
  const {
1145
1175
  sizesKnown,
1146
1176
  sizes,
1147
- scrollingTo,
1148
1177
  averageSizes,
1149
1178
  props: { estimatedItemSize, getEstimatedItemSize, getFixedItemSize, getItemType }
1150
1179
  } = state;
@@ -1154,6 +1183,7 @@ function getItemSize(state, key, index, data, useAverageSize) {
1154
1183
  }
1155
1184
  let size;
1156
1185
  const itemType = getItemType ? (_a3 = getItemType(data, index)) != null ? _a3 : "" : "";
1186
+ const scrollingTo = peek$(ctx, "scrollingTo");
1157
1187
  if (getFixedItemSize) {
1158
1188
  size = getFixedItemSize(index, data, itemType);
1159
1189
  if (size !== void 0) {
@@ -1180,41 +1210,212 @@ function getItemSize(state, key, index, data, useAverageSize) {
1180
1210
  }
1181
1211
 
1182
1212
  // src/core/calculateOffsetWithOffsetPosition.ts
1183
- function calculateOffsetWithOffsetPosition(state, offsetParam, params) {
1213
+ function calculateOffsetWithOffsetPosition(ctx, state, offsetParam, params) {
1184
1214
  const { index, viewOffset, viewPosition } = params;
1185
1215
  let offset = offsetParam;
1186
1216
  if (viewOffset) {
1187
1217
  offset -= viewOffset;
1188
1218
  }
1189
1219
  if (viewPosition !== void 0 && index !== void 0) {
1190
- offset -= viewPosition * (state.scrollLength - getItemSize(state, getId(state, index), index, state.props.data[index]));
1220
+ offset -= viewPosition * (state.scrollLength - getItemSize(ctx, state, getId(state, index), index, state.props.data[index]));
1191
1221
  }
1192
1222
  return offset;
1193
1223
  }
1194
1224
 
1225
+ // src/utils/checkThreshold.ts
1226
+ var HYSTERESIS_MULTIPLIER = 1.3;
1227
+ var checkThreshold = (distance, atThreshold, threshold, wasReached, snapshot, context, onReached, setSnapshot) => {
1228
+ const absDistance = Math.abs(distance);
1229
+ const within = atThreshold || threshold > 0 && absDistance <= threshold;
1230
+ const updateSnapshot = () => {
1231
+ setSnapshot == null ? void 0 : setSnapshot({
1232
+ atThreshold,
1233
+ contentSize: context.contentSize,
1234
+ dataLength: context.dataLength,
1235
+ scrollPosition: context.scrollPosition
1236
+ });
1237
+ };
1238
+ if (!wasReached) {
1239
+ if (!within) {
1240
+ return false;
1241
+ }
1242
+ onReached == null ? void 0 : onReached(distance);
1243
+ updateSnapshot();
1244
+ return true;
1245
+ }
1246
+ const reset = !atThreshold && threshold > 0 && absDistance >= threshold * HYSTERESIS_MULTIPLIER || !atThreshold && threshold <= 0 && absDistance > 0;
1247
+ if (reset) {
1248
+ setSnapshot == null ? void 0 : setSnapshot(void 0);
1249
+ return false;
1250
+ }
1251
+ if (within) {
1252
+ const changed = !snapshot || snapshot.atThreshold !== atThreshold || snapshot.contentSize !== context.contentSize || snapshot.dataLength !== context.dataLength;
1253
+ if (changed) {
1254
+ onReached == null ? void 0 : onReached(distance);
1255
+ updateSnapshot();
1256
+ }
1257
+ }
1258
+ return true;
1259
+ };
1260
+
1261
+ // src/utils/checkAtBottom.ts
1262
+ function checkAtBottom(ctx, state) {
1263
+ var _a3;
1264
+ if (!state) {
1265
+ return;
1266
+ }
1267
+ const {
1268
+ queuedInitialLayout,
1269
+ scrollLength,
1270
+ scroll,
1271
+ maintainingScrollAtEnd,
1272
+ props: { maintainScrollAtEndThreshold, onEndReachedThreshold }
1273
+ } = state;
1274
+ const contentSize = getContentSize(ctx);
1275
+ if (contentSize > 0 && queuedInitialLayout && !maintainingScrollAtEnd) {
1276
+ const distanceFromEnd = contentSize - scroll - scrollLength;
1277
+ const isContentLess = contentSize < scrollLength;
1278
+ state.isAtEnd = isContentLess || distanceFromEnd < scrollLength * maintainScrollAtEndThreshold;
1279
+ state.isEndReached = checkThreshold(
1280
+ distanceFromEnd,
1281
+ isContentLess,
1282
+ onEndReachedThreshold * scrollLength,
1283
+ state.isEndReached,
1284
+ state.endReachedSnapshot,
1285
+ {
1286
+ contentSize,
1287
+ dataLength: (_a3 = state.props.data) == null ? void 0 : _a3.length,
1288
+ scrollPosition: scroll
1289
+ },
1290
+ (distance) => {
1291
+ var _a4, _b;
1292
+ return (_b = (_a4 = state.props).onEndReached) == null ? void 0 : _b.call(_a4, { distanceFromEnd: distance });
1293
+ },
1294
+ (snapshot) => {
1295
+ state.endReachedSnapshot = snapshot;
1296
+ }
1297
+ );
1298
+ }
1299
+ }
1300
+
1301
+ // src/utils/checkAtTop.ts
1302
+ function checkAtTop(state) {
1303
+ var _a3;
1304
+ if (!state) {
1305
+ return;
1306
+ }
1307
+ const {
1308
+ scrollLength,
1309
+ scroll,
1310
+ props: { onStartReachedThreshold }
1311
+ } = state;
1312
+ const distanceFromTop = scroll;
1313
+ state.isAtStart = distanceFromTop <= 0;
1314
+ state.isStartReached = checkThreshold(
1315
+ distanceFromTop,
1316
+ false,
1317
+ onStartReachedThreshold * scrollLength,
1318
+ state.isStartReached,
1319
+ state.startReachedSnapshot,
1320
+ {
1321
+ contentSize: state.totalSize,
1322
+ dataLength: (_a3 = state.props.data) == null ? void 0 : _a3.length,
1323
+ scrollPosition: scroll
1324
+ },
1325
+ (distance) => {
1326
+ var _a4, _b;
1327
+ return (_b = (_a4 = state.props).onStartReached) == null ? void 0 : _b.call(_a4, { distanceFromStart: distance });
1328
+ },
1329
+ (snapshot) => {
1330
+ state.startReachedSnapshot = snapshot;
1331
+ }
1332
+ );
1333
+ }
1334
+
1335
+ // src/core/onScroll.ts
1336
+ function onScroll(ctx, state, event) {
1337
+ var _a3, _b, _c;
1338
+ const {
1339
+ scrollProcessingEnabled,
1340
+ props: { onScroll: onScrollProp }
1341
+ } = state;
1342
+ if (scrollProcessingEnabled === false) {
1343
+ return;
1344
+ }
1345
+ if (((_b = (_a3 = event.nativeEvent) == null ? void 0 : _a3.contentSize) == null ? void 0 : _b.height) === 0 && ((_c = event.nativeEvent.contentSize) == null ? void 0 : _c.width) === 0) {
1346
+ return;
1347
+ }
1348
+ const newScroll = event.nativeEvent.contentOffset[state.props.horizontal ? "x" : "y"];
1349
+ state.scrollPending = newScroll;
1350
+ updateScroll(ctx, state, newScroll);
1351
+ onScrollProp == null ? void 0 : onScrollProp(event);
1352
+ }
1353
+ function updateScroll(ctx, state, newScroll, forceUpdate) {
1354
+ const scrollingTo = peek$(ctx, "scrollingTo");
1355
+ state.hasScrolled = true;
1356
+ state.lastBatchingAction = Date.now();
1357
+ const currentTime = Date.now();
1358
+ const adjust = state.scrollAdjustHandler.getAdjust();
1359
+ const lastHistoryAdjust = state.lastScrollAdjustForHistory;
1360
+ const adjustChanged = lastHistoryAdjust !== void 0 && Math.abs(adjust - lastHistoryAdjust) > 0.1;
1361
+ if (adjustChanged) {
1362
+ state.scrollHistory.length = 0;
1363
+ }
1364
+ state.lastScrollAdjustForHistory = adjust;
1365
+ if (scrollingTo === void 0 && !(state.scrollHistory.length === 0 && newScroll === state.scroll)) {
1366
+ if (!adjustChanged) {
1367
+ state.scrollHistory.push({ scroll: newScroll, time: currentTime });
1368
+ }
1369
+ }
1370
+ if (state.scrollHistory.length > 5) {
1371
+ state.scrollHistory.shift();
1372
+ }
1373
+ state.scrollPrev = state.scroll;
1374
+ state.scrollPrevTime = state.scrollTime;
1375
+ state.scroll = newScroll;
1376
+ state.scrollTime = currentTime;
1377
+ const ignoreScrollFromMVCP = state.ignoreScrollFromMVCP;
1378
+ if (ignoreScrollFromMVCP && !scrollingTo) {
1379
+ const { lt, gt } = ignoreScrollFromMVCP;
1380
+ if (lt && newScroll < lt || gt && newScroll > gt) {
1381
+ state.ignoreScrollFromMVCPIgnored = true;
1382
+ return;
1383
+ }
1384
+ }
1385
+ if (state.dataChangeNeedsScrollUpdate || Math.abs(state.scroll - state.scrollPrev) > 2) {
1386
+ state.ignoreScrollFromMVCPIgnored = false;
1387
+ calculateItemsInView(ctx, state, { doMVCP: scrollingTo !== void 0 });
1388
+ checkAtBottom(ctx, state);
1389
+ checkAtTop(state);
1390
+ state.dataChangeNeedsScrollUpdate = false;
1391
+ }
1392
+ }
1393
+
1195
1394
  // src/core/finishScrollTo.ts
1196
- var finishScrollTo = (state) => {
1395
+ function finishScrollTo(ctx, state) {
1197
1396
  if (state) {
1198
- state.scrollingTo = void 0;
1199
1397
  state.scrollHistory.length = 0;
1398
+ state.initialScroll = void 0;
1399
+ set$(ctx, "scrollingTo", void 0);
1200
1400
  }
1201
- };
1401
+ }
1202
1402
 
1203
1403
  // src/core/scrollTo.ts
1204
- function scrollTo(state, params = {}) {
1404
+ function scrollTo(ctx, state, params) {
1205
1405
  var _a3;
1206
- const { animated, noScrollingTo, isInitialScroll } = params;
1406
+ const { noScrollingTo, ...scrollTarget } = params;
1407
+ const { animated, isInitialScroll, offset: scrollTargetOffset } = scrollTarget;
1207
1408
  const {
1208
1409
  refScroller,
1209
1410
  props: { horizontal }
1210
1411
  } = state;
1211
- const offset = calculateOffsetWithOffsetPosition(state, params.offset, params);
1412
+ const offset = calculateOffsetWithOffsetPosition(ctx, state, scrollTargetOffset, scrollTarget);
1212
1413
  state.scrollHistory.length = 0;
1213
1414
  if (!noScrollingTo) {
1214
- state.scrollingTo = params;
1415
+ set$(ctx, "scrollingTo", scrollTarget);
1215
1416
  }
1216
1417
  state.scrollPending = offset;
1217
- if (!params.isInitialScroll || Platform.OS === "android") {
1418
+ if (!isInitialScroll || Platform.OS === "android") {
1218
1419
  (_a3 = refScroller.current) == null ? void 0 : _a3.scrollTo({
1219
1420
  animated: !!animated,
1220
1421
  x: horizontal ? offset : 0,
@@ -1223,7 +1424,7 @@ function scrollTo(state, params = {}) {
1223
1424
  }
1224
1425
  if (!animated) {
1225
1426
  state.scroll = offset;
1226
- setTimeout(() => finishScrollTo(state), 100);
1427
+ setTimeout(() => finishScrollTo(ctx, state), 100);
1227
1428
  if (isInitialScroll) {
1228
1429
  setTimeout(() => {
1229
1430
  state.initialScroll = void 0;
@@ -1245,24 +1446,6 @@ function requestAdjust(ctx, state, positionDiff, dataChanged) {
1245
1446
  const didLayout = peek$(ctx, "containersDidLayout");
1246
1447
  if (didLayout) {
1247
1448
  doit();
1248
- const threshold = state.scroll - positionDiff / 2;
1249
- if (!state.ignoreScrollFromMVCP) {
1250
- state.ignoreScrollFromMVCP = {};
1251
- }
1252
- if (positionDiff > 0) {
1253
- state.ignoreScrollFromMVCP.lt = threshold;
1254
- } else {
1255
- state.ignoreScrollFromMVCP.gt = threshold;
1256
- }
1257
- if (state.ignoreScrollFromMVCPTimeout) {
1258
- clearTimeout(state.ignoreScrollFromMVCPTimeout);
1259
- }
1260
- state.ignoreScrollFromMVCPTimeout = setTimeout(
1261
- () => {
1262
- state.ignoreScrollFromMVCP = void 0;
1263
- },
1264
- 100
1265
- );
1266
1449
  } else {
1267
1450
  requestAnimationFrame(doit);
1268
1451
  }
@@ -1274,9 +1457,9 @@ function prepareMVCP(ctx, state, dataChanged) {
1274
1457
  const {
1275
1458
  idsInView,
1276
1459
  positions,
1277
- scrollingTo,
1278
1460
  props: { maintainVisibleContentPosition }
1279
1461
  } = state;
1462
+ const scrollingTo = peek$(ctx, "scrollingTo");
1280
1463
  let prevPosition;
1281
1464
  let targetId;
1282
1465
  const idsInViewWithPositions = [];
@@ -1352,7 +1535,7 @@ function prepareColumnStartState(ctx, state, startIndex, useAverageSize) {
1352
1535
  const prevId = state.idCache[prevIndex];
1353
1536
  const prevPosition = (_a3 = state.positions.get(prevId)) != null ? _a3 : 0;
1354
1537
  const prevRowStart = findRowStartIndex(state, numColumns, prevIndex);
1355
- const prevRowHeight = calculateRowMaxSize(state, prevRowStart, prevIndex, useAverageSize);
1538
+ const prevRowHeight = calculateRowMaxSize(ctx, state, prevRowStart, prevIndex, useAverageSize);
1356
1539
  currentRowTop = prevPosition + prevRowHeight;
1357
1540
  }
1358
1541
  return {
@@ -1375,7 +1558,7 @@ function findRowStartIndex(state, numColumns, index) {
1375
1558
  }
1376
1559
  return rowStart;
1377
1560
  }
1378
- function calculateRowMaxSize(state, startIndex, endIndex, useAverageSize) {
1561
+ function calculateRowMaxSize(ctx, state, startIndex, endIndex, useAverageSize) {
1379
1562
  if (endIndex < startIndex) {
1380
1563
  return 0;
1381
1564
  }
@@ -1389,7 +1572,7 @@ function calculateRowMaxSize(state, startIndex, endIndex, useAverageSize) {
1389
1572
  continue;
1390
1573
  }
1391
1574
  const id = state.idCache[i];
1392
- const size = getItemSize(state, id, i, data[i], useAverageSize);
1575
+ const size = getItemSize(ctx, state, id, i, data[i], useAverageSize);
1393
1576
  if (size > maxSize) {
1394
1577
  maxSize = size;
1395
1578
  }
@@ -1445,7 +1628,7 @@ function updateTotalSize(ctx, state) {
1445
1628
  if (lastId !== void 0) {
1446
1629
  const lastPosition = positions.get(lastId);
1447
1630
  if (lastPosition !== void 0) {
1448
- const lastSize = getItemSize(state, lastId, data.length - 1, data[data.length - 1]);
1631
+ const lastSize = getItemSize(ctx, state, lastId, data.length - 1, data[data.length - 1]);
1449
1632
  if (lastSize !== void 0) {
1450
1633
  const totalSize = lastPosition + lastSize;
1451
1634
  addTotalSize(ctx, state, null, totalSize);
@@ -1503,6 +1686,7 @@ function updateItemPositions(ctx, state, dataChanged, { startIndex, scrollBottom
1503
1686
  const data = state.props.data;
1504
1687
  const dataLength = data.length;
1505
1688
  const numColumns = peek$(ctx, "numColumns");
1689
+ const scrollingTo = peek$(ctx, "scrollingTo");
1506
1690
  const hasColumns = numColumns > 1;
1507
1691
  const indexByKeyForChecking = IS_DEV ? /* @__PURE__ */ new Map() : void 0;
1508
1692
  const maxVisibleArea = scrollBottomBuffered + 1e3;
@@ -1524,7 +1708,7 @@ function updateItemPositions(ctx, state, dataChanged, { startIndex, scrollBottom
1524
1708
  const prevIndex = startIndex - 1;
1525
1709
  const prevId = getId(state, prevIndex);
1526
1710
  const prevPosition = (_a3 = positions.get(prevId)) != null ? _a3 : 0;
1527
- const prevSize = (_b = sizesKnown.get(prevId)) != null ? _b : getItemSize(state, prevId, prevIndex, data[prevIndex], useAverageSize);
1711
+ const prevSize = (_b = sizesKnown.get(prevId)) != null ? _b : getItemSize(ctx, state, prevId, prevIndex, data[prevIndex], useAverageSize);
1528
1712
  currentRowTop = prevPosition + prevSize;
1529
1713
  }
1530
1714
  }
@@ -1536,12 +1720,12 @@ function updateItemPositions(ctx, state, dataChanged, { startIndex, scrollBottom
1536
1720
  didBreakEarly = true;
1537
1721
  break;
1538
1722
  }
1539
- if (breakAt === void 0 && !dataChanged && currentRowTop > maxVisibleArea) {
1723
+ if (breakAt === void 0 && !scrollingTo && !dataChanged && currentRowTop > maxVisibleArea) {
1540
1724
  const itemsPerRow = hasColumns ? numColumns : 1;
1541
1725
  breakAt = i + itemsPerRow + 10;
1542
1726
  }
1543
1727
  const id = (_c = idCache[i]) != null ? _c : getId(state, i);
1544
- const size = (_d = sizesKnown.get(id)) != null ? _d : getItemSize(state, id, i, data[i], useAverageSize);
1728
+ const size = (_d = sizesKnown.get(id)) != null ? _d : getItemSize(ctx, state, id, i, data[i], useAverageSize);
1545
1729
  if (IS_DEV && needsIndexByKey) {
1546
1730
  if (indexByKeyForChecking.has(id)) {
1547
1731
  console.error(
@@ -1965,7 +2149,7 @@ function scrollToIndex(ctx, state, { index, viewOffset = 0, animated = true, vie
1965
2149
  viewPosition = 1;
1966
2150
  }
1967
2151
  state.scrollForNextCalculateItemsInView = void 0;
1968
- scrollTo(state, {
2152
+ scrollTo(ctx, state, {
1969
2153
  animated,
1970
2154
  index,
1971
2155
  offset: firstIndexOffset,
@@ -1974,82 +2158,6 @@ function scrollToIndex(ctx, state, { index, viewOffset = 0, animated = true, vie
1974
2158
  });
1975
2159
  }
1976
2160
 
1977
- // src/utils/checkThreshold.ts
1978
- var HYSTERESIS_MULTIPLIER = 1.3;
1979
- var checkThreshold = (distance, atThreshold, threshold, wasReached, snapshot, context, onReached, setSnapshot) => {
1980
- const absDistance = Math.abs(distance);
1981
- const within = atThreshold || threshold > 0 && absDistance <= threshold;
1982
- const updateSnapshot = () => {
1983
- setSnapshot == null ? void 0 : setSnapshot({
1984
- atThreshold,
1985
- contentSize: context.contentSize,
1986
- dataLength: context.dataLength,
1987
- scrollPosition: context.scrollPosition
1988
- });
1989
- };
1990
- if (!wasReached) {
1991
- if (!within) {
1992
- return false;
1993
- }
1994
- onReached == null ? void 0 : onReached(distance);
1995
- updateSnapshot();
1996
- return true;
1997
- }
1998
- const reset = !atThreshold && threshold > 0 && absDistance >= threshold * HYSTERESIS_MULTIPLIER || !atThreshold && threshold <= 0 && absDistance > 0;
1999
- if (reset) {
2000
- setSnapshot == null ? void 0 : setSnapshot(void 0);
2001
- return false;
2002
- }
2003
- if (within) {
2004
- const changed = !snapshot || snapshot.atThreshold !== atThreshold || snapshot.contentSize !== context.contentSize || snapshot.dataLength !== context.dataLength;
2005
- if (changed) {
2006
- onReached == null ? void 0 : onReached(distance);
2007
- updateSnapshot();
2008
- }
2009
- }
2010
- return true;
2011
- };
2012
-
2013
- // src/utils/checkAtBottom.ts
2014
- function checkAtBottom(ctx, state) {
2015
- var _a3;
2016
- if (!state) {
2017
- return;
2018
- }
2019
- const {
2020
- queuedInitialLayout,
2021
- scrollLength,
2022
- scroll,
2023
- maintainingScrollAtEnd,
2024
- props: { maintainScrollAtEndThreshold, onEndReachedThreshold }
2025
- } = state;
2026
- const contentSize = getContentSize(ctx);
2027
- if (contentSize > 0 && queuedInitialLayout && !maintainingScrollAtEnd) {
2028
- const distanceFromEnd = contentSize - scroll - scrollLength;
2029
- const isContentLess = contentSize < scrollLength;
2030
- state.isAtEnd = isContentLess || distanceFromEnd < scrollLength * maintainScrollAtEndThreshold;
2031
- state.isEndReached = checkThreshold(
2032
- distanceFromEnd,
2033
- isContentLess,
2034
- onEndReachedThreshold * scrollLength,
2035
- state.isEndReached,
2036
- state.endReachedSnapshot,
2037
- {
2038
- scrollPosition: scroll,
2039
- contentSize,
2040
- dataLength: (_a3 = state.props.data) == null ? void 0 : _a3.length
2041
- },
2042
- (distance) => {
2043
- var _a4, _b;
2044
- return (_b = (_a4 = state.props).onEndReached) == null ? void 0 : _b.call(_a4, { distanceFromEnd: distance });
2045
- },
2046
- (snapshot) => {
2047
- state.endReachedSnapshot = snapshot;
2048
- }
2049
- );
2050
- }
2051
- }
2052
-
2053
2161
  // src/utils/setDidLayout.ts
2054
2162
  function setDidLayout(ctx, state) {
2055
2163
  const {
@@ -2129,7 +2237,7 @@ function handleStickyRecycling(ctx, state, stickyArray, scroll, scrollBuffer, cu
2129
2237
  const currentId = (_b = state.idCache[itemIndex]) != null ? _b : getId(state, itemIndex);
2130
2238
  if (currentId) {
2131
2239
  const currentPos = state.positions.get(currentId);
2132
- const currentSize = (_c = state.sizes.get(currentId)) != null ? _c : getItemSize(state, currentId, itemIndex, state.props.data[itemIndex]);
2240
+ const currentSize = (_c = state.sizes.get(currentId)) != null ? _c : getItemSize(ctx, state, currentId, itemIndex, state.props.data[itemIndex]);
2133
2241
  shouldRecycle = currentPos !== void 0 && scroll > currentPos + currentSize + scrollBuffer * 3;
2134
2242
  }
2135
2243
  }
@@ -2140,7 +2248,7 @@ function handleStickyRecycling(ctx, state, stickyArray, scroll, scrollBuffer, cu
2140
2248
  }
2141
2249
  function calculateItemsInView(ctx, state, params = {}) {
2142
2250
  unstable_batchedUpdates(() => {
2143
- var _a3, _b, _c, _d, _e, _f, _g, _h, _i;
2251
+ var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j;
2144
2252
  const {
2145
2253
  columns,
2146
2254
  containerItemKeys,
@@ -2173,13 +2281,15 @@ function calculateItemsInView(ctx, state, params = {}) {
2173
2281
  let { scroll: scrollState } = state;
2174
2282
  if (!queuedInitialLayout && initialScroll) {
2175
2283
  const updatedOffset = calculateOffsetWithOffsetPosition(
2284
+ ctx,
2176
2285
  state,
2177
2286
  calculateOffsetForIndex(ctx, state, initialScroll.index),
2178
2287
  initialScroll
2179
2288
  );
2180
2289
  scrollState = updatedOffset;
2181
2290
  }
2182
- const scrollAdjustPad = -topPad;
2291
+ const scrollAdjustPending = (_a3 = peek$(ctx, "scrollAdjustPending")) != null ? _a3 : 0;
2292
+ const scrollAdjustPad = scrollAdjustPending - topPad;
2183
2293
  let scroll = scrollState + scrollExtra + scrollAdjustPad;
2184
2294
  if (scroll + scrollLength > totalSize) {
2185
2295
  scroll = Math.max(0, totalSize - scrollLength);
@@ -2192,6 +2302,7 @@ function calculateItemsInView(ctx, state, params = {}) {
2192
2302
  const currentStickyIdx = stickyIndicesArr.length > 0 ? findCurrentStickyIndex(stickyIndicesArr, scroll, state) : -1;
2193
2303
  const nextActiveStickyIndex = currentStickyIdx >= 0 ? stickyIndicesArr[currentStickyIdx] : void 0;
2194
2304
  state.activeStickyIndex = nextActiveStickyIndex;
2305
+ set$(ctx, "activeStickyIndex", nextActiveStickyIndex);
2195
2306
  let scrollBufferTop = scrollBuffer;
2196
2307
  let scrollBufferBottom = scrollBuffer;
2197
2308
  if (speed > 0 || speed === 0 && scroll < Math.max(50, scrollBuffer)) {
@@ -2216,7 +2327,7 @@ function calculateItemsInView(ctx, state, params = {}) {
2216
2327
  idCache.length = 0;
2217
2328
  positions.clear();
2218
2329
  }
2219
- const startIndex = dataChanged ? 0 : (_a3 = minIndexSizeChanged != null ? minIndexSizeChanged : state.startBuffered) != null ? _a3 : 0;
2330
+ const startIndex = dataChanged ? 0 : (_b = minIndexSizeChanged != null ? minIndexSizeChanged : state.startBuffered) != null ? _b : 0;
2220
2331
  updateItemPositions(ctx, state, dataChanged, { scrollBottomBuffered, startIndex });
2221
2332
  if (minIndexSizeChanged !== void 0) {
2222
2333
  state.minIndexSizeChanged = void 0;
@@ -2229,9 +2340,9 @@ function calculateItemsInView(ctx, state, params = {}) {
2229
2340
  let endBuffered = null;
2230
2341
  let loopStart = !dataChanged && startBufferedIdOrig ? indexByKey.get(startBufferedIdOrig) || 0 : 0;
2231
2342
  for (let i = loopStart; i >= 0; i--) {
2232
- const id = (_b = idCache[i]) != null ? _b : getId(state, i);
2343
+ const id = (_c = idCache[i]) != null ? _c : getId(state, i);
2233
2344
  const top = positions.get(id);
2234
- const size = (_c = sizes.get(id)) != null ? _c : getItemSize(state, id, i, data[i]);
2345
+ const size = (_d = sizes.get(id)) != null ? _d : getItemSize(ctx, state, id, i, data[i]);
2235
2346
  const bottom = top + size;
2236
2347
  if (bottom > scroll - scrollBuffer) {
2237
2348
  loopStart = i;
@@ -2257,8 +2368,8 @@ function calculateItemsInView(ctx, state, params = {}) {
2257
2368
  let firstFullyOnScreenIndex;
2258
2369
  const dataLength = data.length;
2259
2370
  for (let i = Math.max(0, loopStart); i < dataLength && (!foundEnd || i <= maxIndexRendered); i++) {
2260
- const id = (_d = idCache[i]) != null ? _d : getId(state, i);
2261
- const size = (_e = sizes.get(id)) != null ? _e : getItemSize(state, id, i, data[i]);
2371
+ const id = (_e = idCache[i]) != null ? _e : getId(state, i);
2372
+ const size = (_f = sizes.get(id)) != null ? _f : getItemSize(ctx, state, id, i, data[i]);
2262
2373
  const top = positions.get(id);
2263
2374
  if (!foundEnd) {
2264
2375
  if (startNoBuffer === null && top + size > scroll) {
@@ -2287,7 +2398,7 @@ function calculateItemsInView(ctx, state, params = {}) {
2287
2398
  }
2288
2399
  const idsInView = [];
2289
2400
  for (let i = firstFullyOnScreenIndex; i <= endNoBuffer; i++) {
2290
- const id = (_f = idCache[i]) != null ? _f : getId(state, i);
2401
+ const id = (_g = idCache[i]) != null ? _g : getId(state, i);
2291
2402
  idsInView.push(id);
2292
2403
  }
2293
2404
  Object.assign(state, {
@@ -2319,7 +2430,7 @@ function calculateItemsInView(ctx, state, params = {}) {
2319
2430
  let numContainers2 = prevNumContainers;
2320
2431
  const needNewContainers = [];
2321
2432
  for (let i = startBuffered; i <= endBuffered; i++) {
2322
- const id = (_g = idCache[i]) != null ? _g : getId(state, i);
2433
+ const id = (_h = idCache[i]) != null ? _h : getId(state, i);
2323
2434
  if (!containerItemKeys.has(id)) {
2324
2435
  needNewContainers.push(i);
2325
2436
  }
@@ -2337,6 +2448,7 @@ function calculateItemsInView(ctx, state, params = {}) {
2337
2448
  );
2338
2449
  } else {
2339
2450
  state.activeStickyIndex = void 0;
2451
+ set$(ctx, "activeStickyIndex", void 0);
2340
2452
  }
2341
2453
  if (needNewContainers.length > 0) {
2342
2454
  const requiredItemTypes = getItemType ? needNewContainers.map((i) => {
@@ -2356,7 +2468,7 @@ function calculateItemsInView(ctx, state, params = {}) {
2356
2468
  for (let idx = 0; idx < needNewContainers.length; idx++) {
2357
2469
  const i = needNewContainers[idx];
2358
2470
  const containerIndex = availableContainers[idx];
2359
- const id = (_h = idCache[i]) != null ? _h : getId(state, i);
2471
+ const id = (_i = idCache[i]) != null ? _i : getId(state, i);
2360
2472
  const oldKey = peek$(ctx, `containerItemKey${containerIndex}`);
2361
2473
  if (oldKey && oldKey !== id) {
2362
2474
  containerItemKeys.delete(oldKey);
@@ -2412,11 +2524,12 @@ function calculateItemsInView(ctx, state, params = {}) {
2412
2524
  const itemIndex = indexByKey.get(itemKey);
2413
2525
  const item = data[itemIndex];
2414
2526
  if (item !== void 0) {
2415
- const id = (_i = idCache[itemIndex]) != null ? _i : getId(state, itemIndex);
2416
- const position = positions.get(id);
2417
- if (position === void 0) {
2527
+ const id = (_j = idCache[itemIndex]) != null ? _j : getId(state, itemIndex);
2528
+ const positionValue = positions.get(id);
2529
+ if (positionValue === void 0) {
2418
2530
  set$(ctx, `containerPosition${i}`, POSITION_OUT_OF_VIEW);
2419
2531
  } else {
2532
+ const position = (positionValue || 0) - scrollAdjustPending;
2420
2533
  const column = columns.get(id) || 1;
2421
2534
  const prevPos = peek$(ctx, `containerPosition${i}`);
2422
2535
  const prevColumn = peek$(ctx, `containerColumn${i}`);
@@ -2485,40 +2598,6 @@ function doMaintainScrollAtEnd(ctx, state, animated) {
2485
2598
  }
2486
2599
  }
2487
2600
 
2488
- // src/utils/checkAtTop.ts
2489
- function checkAtTop(state) {
2490
- var _a3;
2491
- if (!state) {
2492
- return;
2493
- }
2494
- const {
2495
- scrollLength,
2496
- scroll,
2497
- props: { onStartReachedThreshold }
2498
- } = state;
2499
- const distanceFromTop = scroll;
2500
- state.isAtStart = distanceFromTop <= 0;
2501
- state.isStartReached = checkThreshold(
2502
- distanceFromTop,
2503
- false,
2504
- onStartReachedThreshold * scrollLength,
2505
- state.isStartReached,
2506
- state.startReachedSnapshot,
2507
- {
2508
- scrollPosition: scroll,
2509
- contentSize: state.totalSize,
2510
- dataLength: (_a3 = state.props.data) == null ? void 0 : _a3.length
2511
- },
2512
- (distance) => {
2513
- var _a4, _b;
2514
- return (_b = (_a4 = state.props).onStartReached) == null ? void 0 : _b.call(_a4, { distanceFromStart: distance });
2515
- },
2516
- (snapshot) => {
2517
- state.startReachedSnapshot = snapshot;
2518
- }
2519
- );
2520
- }
2521
-
2522
2601
  // src/utils/updateAveragesOnDataChange.ts
2523
2602
  function updateAveragesOnDataChange(state, oldData, newData) {
2524
2603
  var _a3;
@@ -2687,78 +2766,47 @@ function handleLayout(ctx, state, layout, setCanRender) {
2687
2766
  setCanRender(true);
2688
2767
  }
2689
2768
 
2690
- // src/core/onScroll.ts
2691
- function onScroll(ctx, state, event) {
2692
- var _a3, _b, _c;
2693
- const {
2694
- scrollProcessingEnabled,
2695
- props: { onScroll: onScrollProp }
2696
- } = state;
2697
- if (scrollProcessingEnabled === false) {
2698
- return;
2699
- }
2700
- if (((_b = (_a3 = event.nativeEvent) == null ? void 0 : _a3.contentSize) == null ? void 0 : _b.height) === 0 && ((_c = event.nativeEvent.contentSize) == null ? void 0 : _c.width) === 0) {
2701
- return;
2702
- }
2703
- const newScroll = event.nativeEvent.contentOffset[state.props.horizontal ? "x" : "y"];
2704
- state.scrollPending = newScroll;
2705
- updateScroll(ctx, state, newScroll);
2706
- onScrollProp == null ? void 0 : onScrollProp(event);
2707
- }
2708
- function updateScroll(ctx, state, newScroll) {
2709
- const scrollingTo = state.scrollingTo;
2710
- state.hasScrolled = true;
2711
- state.lastBatchingAction = Date.now();
2712
- const currentTime = Date.now();
2713
- const adjust = state.scrollAdjustHandler.getAdjust();
2714
- const lastHistoryAdjust = state.lastScrollAdjustForHistory;
2715
- const adjustChanged = lastHistoryAdjust !== void 0 && Math.abs(adjust - lastHistoryAdjust) > 0.1;
2716
- if (adjustChanged) {
2717
- state.scrollHistory.length = 0;
2718
- }
2719
- state.lastScrollAdjustForHistory = adjust;
2720
- if (scrollingTo === void 0 && !(state.scrollHistory.length === 0 && newScroll === state.scroll)) {
2721
- if (!adjustChanged) {
2722
- state.scrollHistory.push({ scroll: newScroll, time: currentTime });
2723
- }
2724
- }
2725
- if (state.scrollHistory.length > 5) {
2726
- state.scrollHistory.shift();
2727
- }
2728
- state.scrollPrev = state.scroll;
2729
- state.scrollPrevTime = state.scrollTime;
2730
- state.scroll = newScroll;
2731
- state.scrollTime = currentTime;
2732
- const ignoreScrollFromMVCP = state.ignoreScrollFromMVCP;
2733
- if (ignoreScrollFromMVCP && !state.scrollingTo) {
2734
- const { lt, gt } = ignoreScrollFromMVCP;
2735
- if (lt && newScroll < lt || gt && newScroll > gt) {
2736
- return;
2737
- }
2738
- }
2739
- if (state.dataChangeNeedsScrollUpdate || Math.abs(state.scroll - state.scrollPrev) > 2) {
2740
- calculateItemsInView(ctx, state, { doMVCP: state.scrollingTo !== void 0 });
2741
- checkAtBottom(ctx, state);
2742
- checkAtTop(state);
2743
- state.dataChangeNeedsScrollUpdate = false;
2744
- }
2745
- }
2746
-
2747
2769
  // src/core/ScrollAdjustHandler.ts
2748
2770
  var ScrollAdjustHandler = class {
2749
2771
  constructor(ctx) {
2750
2772
  this.appliedAdjust = 0;
2773
+ this.pendingAdjust = 0;
2751
2774
  this.mounted = false;
2752
2775
  this.context = ctx;
2776
+ {
2777
+ const commitPendingAdjust = () => {
2778
+ const state = this.context.internalState;
2779
+ const pending = this.pendingAdjust;
2780
+ if (pending !== 0) {
2781
+ this.pendingAdjust = 0;
2782
+ this.appliedAdjust += pending;
2783
+ state.scroll += pending;
2784
+ state.scrollForNextCalculateItemsInView = void 0;
2785
+ set$(this.context, "scrollAdjustPending", 0);
2786
+ set$(this.context, "scrollAdjust", this.appliedAdjust);
2787
+ calculateItemsInView(this.context, this.context.internalState);
2788
+ }
2789
+ };
2790
+ listen$(this.context, "scrollingTo", (value) => {
2791
+ if (value === void 0) {
2792
+ commitPendingAdjust();
2793
+ }
2794
+ });
2795
+ }
2753
2796
  }
2754
2797
  requestAdjust(add) {
2755
- const oldAdjustTop = this.appliedAdjust;
2756
- this.appliedAdjust = add + oldAdjustTop;
2757
- const set = () => set$(this.context, "scrollAdjust", this.appliedAdjust);
2758
- if (this.mounted) {
2759
- set();
2798
+ const scrollingTo = peek$(this.context, "scrollingTo");
2799
+ if ((scrollingTo == null ? void 0 : scrollingTo.animated) && !scrollingTo.isInitialScroll) {
2800
+ this.pendingAdjust += add;
2801
+ set$(this.context, "scrollAdjustPending", this.pendingAdjust);
2760
2802
  } else {
2761
- requestAnimationFrame(set);
2803
+ this.appliedAdjust += add;
2804
+ const setter = () => set$(this.context, "scrollAdjust", this.appliedAdjust);
2805
+ if (this.mounted) {
2806
+ setter();
2807
+ } else {
2808
+ requestAnimationFrame(setter);
2809
+ }
2762
2810
  }
2763
2811
  }
2764
2812
  setMounted() {
@@ -2806,7 +2854,7 @@ function updateItemSize(ctx, state, itemKey, sizeObj) {
2806
2854
  let minIndexSizeChanged;
2807
2855
  let maxOtherAxisSize = peek$(ctx, "otherAxisSize") || 0;
2808
2856
  const prevSizeKnown = state.sizesKnown.get(itemKey);
2809
- const diff = updateOneItemSize(state, itemKey, sizeObj);
2857
+ const diff = updateOneItemSize(ctx, state, itemKey, sizeObj);
2810
2858
  const size = Math.floor((horizontal ? sizeObj.width : sizeObj.height) * 8) / 8;
2811
2859
  if (diff !== 0) {
2812
2860
  minIndexSizeChanged = minIndexSizeChanged !== void 0 ? Math.min(minIndexSizeChanged, index) : index;
@@ -2868,7 +2916,7 @@ function updateItemSize(ctx, state, itemKey, sizeObj) {
2868
2916
  }
2869
2917
  }
2870
2918
  }
2871
- function updateOneItemSize(state, itemKey, sizeObj) {
2919
+ function updateOneItemSize(ctx, state, itemKey, sizeObj) {
2872
2920
  var _a3;
2873
2921
  const {
2874
2922
  sizes,
@@ -2879,7 +2927,7 @@ function updateOneItemSize(state, itemKey, sizeObj) {
2879
2927
  } = state;
2880
2928
  if (!data) return 0;
2881
2929
  const index = indexByKey.get(itemKey);
2882
- const prevSize = getItemSize(state, itemKey, index, data[index]);
2930
+ const prevSize = getItemSize(ctx, state, itemKey, index, data[index]);
2883
2931
  const rawSize = horizontal ? sizeObj.width : sizeObj.height;
2884
2932
  const size = Math.round(rawSize) ;
2885
2933
  sizesKnown.set(itemKey, size);
@@ -3087,7 +3135,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3087
3135
  ...rest
3088
3136
  } = props;
3089
3137
  const [renderNum, setRenderNum] = useState(0);
3090
- const initialScroll = initialScrollIndexProp || initialScrollOffsetProp ? typeof initialScrollIndexProp === "object" ? { index: initialScrollIndexProp.index || 0, viewOffset: initialScrollIndexProp.viewOffset || 0 } : { index: initialScrollIndexProp || 0, viewOffset: initialScrollOffsetProp || 0 } : void 0;
3138
+ const initialScrollProp = initialScrollIndexProp || initialScrollOffsetProp ? typeof initialScrollIndexProp === "object" ? { index: initialScrollIndexProp.index || 0, viewOffset: initialScrollIndexProp.viewOffset || 0 } : { index: initialScrollIndexProp || 0, viewOffset: initialScrollOffsetProp || 0 } : void 0;
3091
3139
  const [canRender, setCanRender] = React3.useState(!IsNewArchitecture);
3092
3140
  const contentContainerStyle = { ...StyleSheet.flatten(contentContainerStyleProp) };
3093
3141
  const style = { ...StyleSheet.flatten(styleProp) };
@@ -3119,7 +3167,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3119
3167
  idCache: [],
3120
3168
  idsInView: [],
3121
3169
  indexByKey: /* @__PURE__ */ new Map(),
3122
- initialScroll,
3170
+ initialScroll: initialScrollProp,
3123
3171
  isAtEnd: false,
3124
3172
  isAtStart: false,
3125
3173
  isEndReached: false,
@@ -3177,7 +3225,6 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3177
3225
  getItemType,
3178
3226
  horizontal: !!horizontal,
3179
3227
  initialContainerPoolRatio,
3180
- initialScroll,
3181
3228
  itemsAreEqual,
3182
3229
  keyExtractor,
3183
3230
  maintainScrollAtEnd,
@@ -3234,6 +3281,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3234
3281
  );
3235
3282
  }
3236
3283
  const initialContentOffset = useMemo(() => {
3284
+ const { initialScroll } = refState.current;
3237
3285
  if (initialScroll) {
3238
3286
  const { index, viewOffset } = initialScroll;
3239
3287
  let initialContentOffset2 = viewOffset || 0;
@@ -3242,7 +3290,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3242
3290
  }
3243
3291
  refState.current.isStartReached = initialContentOffset2 < refState.current.scrollLength * onStartReachedThreshold;
3244
3292
  if (initialContentOffset2 > 0) {
3245
- scrollTo(state, {
3293
+ scrollTo(ctx, state, {
3246
3294
  animated: false,
3247
3295
  index,
3248
3296
  isInitialScroll: true,
@@ -3266,6 +3314,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3266
3314
  }
3267
3315
  }
3268
3316
  const onLayoutHeader = useCallback((rect, fromLayoutEffect) => {
3317
+ const { initialScroll } = refState.current;
3269
3318
  const size = rect[horizontal ? "width" : "height"];
3270
3319
  set$(ctx, "headerSize", size);
3271
3320
  if ((initialScroll == null ? void 0 : initialScroll.index) !== void 0) {
@@ -3392,7 +3441,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3392
3441
  scrollToIndex(ctx, state, { index, ...props2 });
3393
3442
  }
3394
3443
  },
3395
- scrollToOffset: (params) => scrollTo(state, params),
3444
+ scrollToOffset: (params) => scrollTo(ctx, state, params),
3396
3445
  setScrollProcessingEnabled: (enabled) => {
3397
3446
  refState.current.scrollProcessingEnabled = enabled;
3398
3447
  },
@@ -3404,8 +3453,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3404
3453
  }, []);
3405
3454
  {
3406
3455
  useEffect(() => {
3456
+ const { initialScroll } = refState.current;
3407
3457
  if (initialContentOffset) {
3408
- scrollTo(state, { animated: false, offset: initialContentOffset, ...initialScroll || {} });
3458
+ scrollTo(ctx, state, { animated: false, offset: initialContentOffset, ...initialScroll || {} });
3409
3459
  }
3410
3460
  }, []);
3411
3461
  }
@@ -3436,7 +3486,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3436
3486
  onMomentumScrollEnd: (event) => {
3437
3487
  {
3438
3488
  requestAnimationFrame(() => {
3439
- finishScrollTo(refState.current);
3489
+ finishScrollTo(ctx, refState.current);
3440
3490
  });
3441
3491
  }
3442
3492
  if (onMomentumScrollEnd) {