@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.js CHANGED
@@ -54,7 +54,10 @@ function StateProvider({ children }) {
54
54
  ["stylePaddingTop", 0],
55
55
  ["headerSize", 0],
56
56
  ["numContainers", 0],
57
- ["totalSize", 0]
57
+ ["activeStickyIndex", void 0],
58
+ ["totalSize", 0],
59
+ ["scrollAdjustPending", 0],
60
+ ["scrollingTo", void 0]
58
61
  ]),
59
62
  viewRefs: /* @__PURE__ */ new Map()
60
63
  }));
@@ -217,8 +220,11 @@ var PositionViewState = typedMemo(function PositionView({
217
220
  ...rest
218
221
  }) {
219
222
  const [position = POSITION_OUT_OF_VIEW] = useArr$([`containerPosition${id}`]);
220
- const base = Array.isArray(style) ? Object.assign({}, ...style) : style;
221
- const combinedStyle = horizontal ? { ...base, left: position } : { ...base, top: position };
223
+ const base = {
224
+ contain: "paint layout style"
225
+ };
226
+ const composed = Array.isArray(style) ? Object.assign({}, ...style) : style;
227
+ const combinedStyle = horizontal ? { ...base, ...composed, left: position } : { ...base, ...composed, top: position };
222
228
  return /* @__PURE__ */ React3__namespace.createElement("div", { ref: refView, style: combinedStyle, ...rest });
223
229
  });
224
230
  var PositionViewSticky = typedMemo(function PositionViewSticky2({
@@ -227,19 +233,42 @@ var PositionViewSticky = typedMemo(function PositionViewSticky2({
227
233
  style,
228
234
  refView,
229
235
  index,
236
+ stickyOffset,
237
+ animatedScrollY: _animatedScrollY,
238
+ children,
230
239
  ...rest
231
240
  }) {
232
- const [position = POSITION_OUT_OF_VIEW, _headerSize] = useArr$([`containerPosition${id}`, "headerSize"]);
241
+ const [position = POSITION_OUT_OF_VIEW, headerSize = 0, activeStickyIndex] = useArr$([
242
+ `containerPosition${id}`,
243
+ "headerSize",
244
+ "activeStickyIndex"
245
+ ]);
246
+ const base = {
247
+ contain: "paint layout style"
248
+ };
249
+ const composed = React3__namespace.useMemo(
250
+ () => {
251
+ var _a3;
252
+ return (_a3 = Array.isArray(style) ? Object.assign({}, ...style) : style) != null ? _a3 : {};
253
+ },
254
+ [style]
255
+ );
233
256
  const viewStyle = React3__namespace.useMemo(() => {
234
- const base = Array.isArray(style) ? Object.assign({}, ...style) : style;
235
- const axisStyle = horizontal ? { transform: `translateX(${position}px)` } : { top: position };
236
- return {
237
- ...base,
238
- zIndex: index + 1e3,
239
- ...axisStyle
240
- };
241
- }, [style, position, horizontal, index]);
242
- return /* @__PURE__ */ React3__namespace.createElement("div", { ref: refView, style: viewStyle, ...rest });
257
+ var _a3;
258
+ const styleBase = { ...base, ...composed };
259
+ delete styleBase.transform;
260
+ const offset = (_a3 = stickyOffset != null ? stickyOffset : headerSize) != null ? _a3 : 0;
261
+ const isActive = activeStickyIndex === index;
262
+ styleBase.position = isActive ? "sticky" : "absolute";
263
+ styleBase.zIndex = index + 1e3;
264
+ if (horizontal) {
265
+ styleBase.left = isActive ? offset : position;
266
+ } else {
267
+ styleBase.top = isActive ? offset : position;
268
+ }
269
+ return styleBase;
270
+ }, [composed, horizontal, position, index, stickyOffset, headerSize, activeStickyIndex]);
271
+ return /* @__PURE__ */ React3__namespace.createElement("div", { ref: refView, style: viewStyle, ...rest }, children);
243
272
  });
244
273
  var PositionView2 = PositionViewState;
245
274
 
@@ -991,10 +1020,11 @@ function PaddingDevMode() {
991
1020
  function useValueListener$(key, callback) {
992
1021
  const ctx = useStateContext();
993
1022
  React3.useLayoutEffect(() => {
994
- listen$(ctx, key, (value) => {
1023
+ const unsubscribe = listen$(ctx, key, (value) => {
995
1024
  callback(value);
996
1025
  });
997
- }, []);
1026
+ return unsubscribe;
1027
+ }, [callback, ctx, key]);
998
1028
  }
999
1029
 
1000
1030
  // src/components/ScrollAdjust.tsx
@@ -1160,12 +1190,11 @@ function calculateOffsetForIndex(ctx, state, index) {
1160
1190
  }
1161
1191
 
1162
1192
  // src/utils/getItemSize.ts
1163
- function getItemSize(state, key, index, data, useAverageSize) {
1193
+ function getItemSize(ctx, state, key, index, data, useAverageSize) {
1164
1194
  var _a3, _b;
1165
1195
  const {
1166
1196
  sizesKnown,
1167
1197
  sizes,
1168
- scrollingTo,
1169
1198
  averageSizes,
1170
1199
  props: { estimatedItemSize, getEstimatedItemSize, getFixedItemSize, getItemType }
1171
1200
  } = state;
@@ -1175,6 +1204,7 @@ function getItemSize(state, key, index, data, useAverageSize) {
1175
1204
  }
1176
1205
  let size;
1177
1206
  const itemType = getItemType ? (_a3 = getItemType(data, index)) != null ? _a3 : "" : "";
1207
+ const scrollingTo = peek$(ctx, "scrollingTo");
1178
1208
  if (getFixedItemSize) {
1179
1209
  size = getFixedItemSize(index, data, itemType);
1180
1210
  if (size !== void 0) {
@@ -1201,41 +1231,212 @@ function getItemSize(state, key, index, data, useAverageSize) {
1201
1231
  }
1202
1232
 
1203
1233
  // src/core/calculateOffsetWithOffsetPosition.ts
1204
- function calculateOffsetWithOffsetPosition(state, offsetParam, params) {
1234
+ function calculateOffsetWithOffsetPosition(ctx, state, offsetParam, params) {
1205
1235
  const { index, viewOffset, viewPosition } = params;
1206
1236
  let offset = offsetParam;
1207
1237
  if (viewOffset) {
1208
1238
  offset -= viewOffset;
1209
1239
  }
1210
1240
  if (viewPosition !== void 0 && index !== void 0) {
1211
- offset -= viewPosition * (state.scrollLength - getItemSize(state, getId(state, index), index, state.props.data[index]));
1241
+ offset -= viewPosition * (state.scrollLength - getItemSize(ctx, state, getId(state, index), index, state.props.data[index]));
1212
1242
  }
1213
1243
  return offset;
1214
1244
  }
1215
1245
 
1246
+ // src/utils/checkThreshold.ts
1247
+ var HYSTERESIS_MULTIPLIER = 1.3;
1248
+ var checkThreshold = (distance, atThreshold, threshold, wasReached, snapshot, context, onReached, setSnapshot) => {
1249
+ const absDistance = Math.abs(distance);
1250
+ const within = atThreshold || threshold > 0 && absDistance <= threshold;
1251
+ const updateSnapshot = () => {
1252
+ setSnapshot == null ? void 0 : setSnapshot({
1253
+ atThreshold,
1254
+ contentSize: context.contentSize,
1255
+ dataLength: context.dataLength,
1256
+ scrollPosition: context.scrollPosition
1257
+ });
1258
+ };
1259
+ if (!wasReached) {
1260
+ if (!within) {
1261
+ return false;
1262
+ }
1263
+ onReached == null ? void 0 : onReached(distance);
1264
+ updateSnapshot();
1265
+ return true;
1266
+ }
1267
+ const reset = !atThreshold && threshold > 0 && absDistance >= threshold * HYSTERESIS_MULTIPLIER || !atThreshold && threshold <= 0 && absDistance > 0;
1268
+ if (reset) {
1269
+ setSnapshot == null ? void 0 : setSnapshot(void 0);
1270
+ return false;
1271
+ }
1272
+ if (within) {
1273
+ const changed = !snapshot || snapshot.atThreshold !== atThreshold || snapshot.contentSize !== context.contentSize || snapshot.dataLength !== context.dataLength;
1274
+ if (changed) {
1275
+ onReached == null ? void 0 : onReached(distance);
1276
+ updateSnapshot();
1277
+ }
1278
+ }
1279
+ return true;
1280
+ };
1281
+
1282
+ // src/utils/checkAtBottom.ts
1283
+ function checkAtBottom(ctx, state) {
1284
+ var _a3;
1285
+ if (!state) {
1286
+ return;
1287
+ }
1288
+ const {
1289
+ queuedInitialLayout,
1290
+ scrollLength,
1291
+ scroll,
1292
+ maintainingScrollAtEnd,
1293
+ props: { maintainScrollAtEndThreshold, onEndReachedThreshold }
1294
+ } = state;
1295
+ const contentSize = getContentSize(ctx);
1296
+ if (contentSize > 0 && queuedInitialLayout && !maintainingScrollAtEnd) {
1297
+ const distanceFromEnd = contentSize - scroll - scrollLength;
1298
+ const isContentLess = contentSize < scrollLength;
1299
+ state.isAtEnd = isContentLess || distanceFromEnd < scrollLength * maintainScrollAtEndThreshold;
1300
+ state.isEndReached = checkThreshold(
1301
+ distanceFromEnd,
1302
+ isContentLess,
1303
+ onEndReachedThreshold * scrollLength,
1304
+ state.isEndReached,
1305
+ state.endReachedSnapshot,
1306
+ {
1307
+ contentSize,
1308
+ dataLength: (_a3 = state.props.data) == null ? void 0 : _a3.length,
1309
+ scrollPosition: scroll
1310
+ },
1311
+ (distance) => {
1312
+ var _a4, _b;
1313
+ return (_b = (_a4 = state.props).onEndReached) == null ? void 0 : _b.call(_a4, { distanceFromEnd: distance });
1314
+ },
1315
+ (snapshot) => {
1316
+ state.endReachedSnapshot = snapshot;
1317
+ }
1318
+ );
1319
+ }
1320
+ }
1321
+
1322
+ // src/utils/checkAtTop.ts
1323
+ function checkAtTop(state) {
1324
+ var _a3;
1325
+ if (!state) {
1326
+ return;
1327
+ }
1328
+ const {
1329
+ scrollLength,
1330
+ scroll,
1331
+ props: { onStartReachedThreshold }
1332
+ } = state;
1333
+ const distanceFromTop = scroll;
1334
+ state.isAtStart = distanceFromTop <= 0;
1335
+ state.isStartReached = checkThreshold(
1336
+ distanceFromTop,
1337
+ false,
1338
+ onStartReachedThreshold * scrollLength,
1339
+ state.isStartReached,
1340
+ state.startReachedSnapshot,
1341
+ {
1342
+ contentSize: state.totalSize,
1343
+ dataLength: (_a3 = state.props.data) == null ? void 0 : _a3.length,
1344
+ scrollPosition: scroll
1345
+ },
1346
+ (distance) => {
1347
+ var _a4, _b;
1348
+ return (_b = (_a4 = state.props).onStartReached) == null ? void 0 : _b.call(_a4, { distanceFromStart: distance });
1349
+ },
1350
+ (snapshot) => {
1351
+ state.startReachedSnapshot = snapshot;
1352
+ }
1353
+ );
1354
+ }
1355
+
1356
+ // src/core/onScroll.ts
1357
+ function onScroll(ctx, state, event) {
1358
+ var _a3, _b, _c;
1359
+ const {
1360
+ scrollProcessingEnabled,
1361
+ props: { onScroll: onScrollProp }
1362
+ } = state;
1363
+ if (scrollProcessingEnabled === false) {
1364
+ return;
1365
+ }
1366
+ 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) {
1367
+ return;
1368
+ }
1369
+ const newScroll = event.nativeEvent.contentOffset[state.props.horizontal ? "x" : "y"];
1370
+ state.scrollPending = newScroll;
1371
+ updateScroll(ctx, state, newScroll);
1372
+ onScrollProp == null ? void 0 : onScrollProp(event);
1373
+ }
1374
+ function updateScroll(ctx, state, newScroll, forceUpdate) {
1375
+ const scrollingTo = peek$(ctx, "scrollingTo");
1376
+ state.hasScrolled = true;
1377
+ state.lastBatchingAction = Date.now();
1378
+ const currentTime = Date.now();
1379
+ const adjust = state.scrollAdjustHandler.getAdjust();
1380
+ const lastHistoryAdjust = state.lastScrollAdjustForHistory;
1381
+ const adjustChanged = lastHistoryAdjust !== void 0 && Math.abs(adjust - lastHistoryAdjust) > 0.1;
1382
+ if (adjustChanged) {
1383
+ state.scrollHistory.length = 0;
1384
+ }
1385
+ state.lastScrollAdjustForHistory = adjust;
1386
+ if (scrollingTo === void 0 && !(state.scrollHistory.length === 0 && newScroll === state.scroll)) {
1387
+ if (!adjustChanged) {
1388
+ state.scrollHistory.push({ scroll: newScroll, time: currentTime });
1389
+ }
1390
+ }
1391
+ if (state.scrollHistory.length > 5) {
1392
+ state.scrollHistory.shift();
1393
+ }
1394
+ state.scrollPrev = state.scroll;
1395
+ state.scrollPrevTime = state.scrollTime;
1396
+ state.scroll = newScroll;
1397
+ state.scrollTime = currentTime;
1398
+ const ignoreScrollFromMVCP = state.ignoreScrollFromMVCP;
1399
+ if (ignoreScrollFromMVCP && !scrollingTo) {
1400
+ const { lt, gt } = ignoreScrollFromMVCP;
1401
+ if (lt && newScroll < lt || gt && newScroll > gt) {
1402
+ state.ignoreScrollFromMVCPIgnored = true;
1403
+ return;
1404
+ }
1405
+ }
1406
+ if (state.dataChangeNeedsScrollUpdate || Math.abs(state.scroll - state.scrollPrev) > 2) {
1407
+ state.ignoreScrollFromMVCPIgnored = false;
1408
+ calculateItemsInView(ctx, state, { doMVCP: scrollingTo !== void 0 });
1409
+ checkAtBottom(ctx, state);
1410
+ checkAtTop(state);
1411
+ state.dataChangeNeedsScrollUpdate = false;
1412
+ }
1413
+ }
1414
+
1216
1415
  // src/core/finishScrollTo.ts
1217
- var finishScrollTo = (state) => {
1416
+ function finishScrollTo(ctx, state) {
1218
1417
  if (state) {
1219
- state.scrollingTo = void 0;
1220
1418
  state.scrollHistory.length = 0;
1419
+ state.initialScroll = void 0;
1420
+ set$(ctx, "scrollingTo", void 0);
1221
1421
  }
1222
- };
1422
+ }
1223
1423
 
1224
1424
  // src/core/scrollTo.ts
1225
- function scrollTo(state, params = {}) {
1425
+ function scrollTo(ctx, state, params) {
1226
1426
  var _a3;
1227
- const { animated, noScrollingTo, isInitialScroll } = params;
1427
+ const { noScrollingTo, ...scrollTarget } = params;
1428
+ const { animated, isInitialScroll, offset: scrollTargetOffset } = scrollTarget;
1228
1429
  const {
1229
1430
  refScroller,
1230
1431
  props: { horizontal }
1231
1432
  } = state;
1232
- const offset = calculateOffsetWithOffsetPosition(state, params.offset, params);
1433
+ const offset = calculateOffsetWithOffsetPosition(ctx, state, scrollTargetOffset, scrollTarget);
1233
1434
  state.scrollHistory.length = 0;
1234
1435
  if (!noScrollingTo) {
1235
- state.scrollingTo = params;
1436
+ set$(ctx, "scrollingTo", scrollTarget);
1236
1437
  }
1237
1438
  state.scrollPending = offset;
1238
- if (!params.isInitialScroll || Platform.OS === "android") {
1439
+ if (!isInitialScroll || Platform.OS === "android") {
1239
1440
  (_a3 = refScroller.current) == null ? void 0 : _a3.scrollTo({
1240
1441
  animated: !!animated,
1241
1442
  x: horizontal ? offset : 0,
@@ -1244,7 +1445,7 @@ function scrollTo(state, params = {}) {
1244
1445
  }
1245
1446
  if (!animated) {
1246
1447
  state.scroll = offset;
1247
- setTimeout(() => finishScrollTo(state), 100);
1448
+ setTimeout(() => finishScrollTo(ctx, state), 100);
1248
1449
  if (isInitialScroll) {
1249
1450
  setTimeout(() => {
1250
1451
  state.initialScroll = void 0;
@@ -1266,24 +1467,6 @@ function requestAdjust(ctx, state, positionDiff, dataChanged) {
1266
1467
  const didLayout = peek$(ctx, "containersDidLayout");
1267
1468
  if (didLayout) {
1268
1469
  doit();
1269
- const threshold = state.scroll - positionDiff / 2;
1270
- if (!state.ignoreScrollFromMVCP) {
1271
- state.ignoreScrollFromMVCP = {};
1272
- }
1273
- if (positionDiff > 0) {
1274
- state.ignoreScrollFromMVCP.lt = threshold;
1275
- } else {
1276
- state.ignoreScrollFromMVCP.gt = threshold;
1277
- }
1278
- if (state.ignoreScrollFromMVCPTimeout) {
1279
- clearTimeout(state.ignoreScrollFromMVCPTimeout);
1280
- }
1281
- state.ignoreScrollFromMVCPTimeout = setTimeout(
1282
- () => {
1283
- state.ignoreScrollFromMVCP = void 0;
1284
- },
1285
- 100
1286
- );
1287
1470
  } else {
1288
1471
  requestAnimationFrame(doit);
1289
1472
  }
@@ -1295,9 +1478,9 @@ function prepareMVCP(ctx, state, dataChanged) {
1295
1478
  const {
1296
1479
  idsInView,
1297
1480
  positions,
1298
- scrollingTo,
1299
1481
  props: { maintainVisibleContentPosition }
1300
1482
  } = state;
1483
+ const scrollingTo = peek$(ctx, "scrollingTo");
1301
1484
  let prevPosition;
1302
1485
  let targetId;
1303
1486
  const idsInViewWithPositions = [];
@@ -1373,7 +1556,7 @@ function prepareColumnStartState(ctx, state, startIndex, useAverageSize) {
1373
1556
  const prevId = state.idCache[prevIndex];
1374
1557
  const prevPosition = (_a3 = state.positions.get(prevId)) != null ? _a3 : 0;
1375
1558
  const prevRowStart = findRowStartIndex(state, numColumns, prevIndex);
1376
- const prevRowHeight = calculateRowMaxSize(state, prevRowStart, prevIndex, useAverageSize);
1559
+ const prevRowHeight = calculateRowMaxSize(ctx, state, prevRowStart, prevIndex, useAverageSize);
1377
1560
  currentRowTop = prevPosition + prevRowHeight;
1378
1561
  }
1379
1562
  return {
@@ -1396,7 +1579,7 @@ function findRowStartIndex(state, numColumns, index) {
1396
1579
  }
1397
1580
  return rowStart;
1398
1581
  }
1399
- function calculateRowMaxSize(state, startIndex, endIndex, useAverageSize) {
1582
+ function calculateRowMaxSize(ctx, state, startIndex, endIndex, useAverageSize) {
1400
1583
  if (endIndex < startIndex) {
1401
1584
  return 0;
1402
1585
  }
@@ -1410,7 +1593,7 @@ function calculateRowMaxSize(state, startIndex, endIndex, useAverageSize) {
1410
1593
  continue;
1411
1594
  }
1412
1595
  const id = state.idCache[i];
1413
- const size = getItemSize(state, id, i, data[i], useAverageSize);
1596
+ const size = getItemSize(ctx, state, id, i, data[i], useAverageSize);
1414
1597
  if (size > maxSize) {
1415
1598
  maxSize = size;
1416
1599
  }
@@ -1466,7 +1649,7 @@ function updateTotalSize(ctx, state) {
1466
1649
  if (lastId !== void 0) {
1467
1650
  const lastPosition = positions.get(lastId);
1468
1651
  if (lastPosition !== void 0) {
1469
- const lastSize = getItemSize(state, lastId, data.length - 1, data[data.length - 1]);
1652
+ const lastSize = getItemSize(ctx, state, lastId, data.length - 1, data[data.length - 1]);
1470
1653
  if (lastSize !== void 0) {
1471
1654
  const totalSize = lastPosition + lastSize;
1472
1655
  addTotalSize(ctx, state, null, totalSize);
@@ -1524,6 +1707,7 @@ function updateItemPositions(ctx, state, dataChanged, { startIndex, scrollBottom
1524
1707
  const data = state.props.data;
1525
1708
  const dataLength = data.length;
1526
1709
  const numColumns = peek$(ctx, "numColumns");
1710
+ const scrollingTo = peek$(ctx, "scrollingTo");
1527
1711
  const hasColumns = numColumns > 1;
1528
1712
  const indexByKeyForChecking = IS_DEV ? /* @__PURE__ */ new Map() : void 0;
1529
1713
  const maxVisibleArea = scrollBottomBuffered + 1e3;
@@ -1545,7 +1729,7 @@ function updateItemPositions(ctx, state, dataChanged, { startIndex, scrollBottom
1545
1729
  const prevIndex = startIndex - 1;
1546
1730
  const prevId = getId(state, prevIndex);
1547
1731
  const prevPosition = (_a3 = positions.get(prevId)) != null ? _a3 : 0;
1548
- const prevSize = (_b = sizesKnown.get(prevId)) != null ? _b : getItemSize(state, prevId, prevIndex, data[prevIndex], useAverageSize);
1732
+ const prevSize = (_b = sizesKnown.get(prevId)) != null ? _b : getItemSize(ctx, state, prevId, prevIndex, data[prevIndex], useAverageSize);
1549
1733
  currentRowTop = prevPosition + prevSize;
1550
1734
  }
1551
1735
  }
@@ -1557,12 +1741,12 @@ function updateItemPositions(ctx, state, dataChanged, { startIndex, scrollBottom
1557
1741
  didBreakEarly = true;
1558
1742
  break;
1559
1743
  }
1560
- if (breakAt === void 0 && !dataChanged && currentRowTop > maxVisibleArea) {
1744
+ if (breakAt === void 0 && !scrollingTo && !dataChanged && currentRowTop > maxVisibleArea) {
1561
1745
  const itemsPerRow = hasColumns ? numColumns : 1;
1562
1746
  breakAt = i + itemsPerRow + 10;
1563
1747
  }
1564
1748
  const id = (_c = idCache[i]) != null ? _c : getId(state, i);
1565
- const size = (_d = sizesKnown.get(id)) != null ? _d : getItemSize(state, id, i, data[i], useAverageSize);
1749
+ const size = (_d = sizesKnown.get(id)) != null ? _d : getItemSize(ctx, state, id, i, data[i], useAverageSize);
1566
1750
  if (IS_DEV && needsIndexByKey) {
1567
1751
  if (indexByKeyForChecking.has(id)) {
1568
1752
  console.error(
@@ -1986,7 +2170,7 @@ function scrollToIndex(ctx, state, { index, viewOffset = 0, animated = true, vie
1986
2170
  viewPosition = 1;
1987
2171
  }
1988
2172
  state.scrollForNextCalculateItemsInView = void 0;
1989
- scrollTo(state, {
2173
+ scrollTo(ctx, state, {
1990
2174
  animated,
1991
2175
  index,
1992
2176
  offset: firstIndexOffset,
@@ -1995,82 +2179,6 @@ function scrollToIndex(ctx, state, { index, viewOffset = 0, animated = true, vie
1995
2179
  });
1996
2180
  }
1997
2181
 
1998
- // src/utils/checkThreshold.ts
1999
- var HYSTERESIS_MULTIPLIER = 1.3;
2000
- var checkThreshold = (distance, atThreshold, threshold, wasReached, snapshot, context, onReached, setSnapshot) => {
2001
- const absDistance = Math.abs(distance);
2002
- const within = atThreshold || threshold > 0 && absDistance <= threshold;
2003
- const updateSnapshot = () => {
2004
- setSnapshot == null ? void 0 : setSnapshot({
2005
- atThreshold,
2006
- contentSize: context.contentSize,
2007
- dataLength: context.dataLength,
2008
- scrollPosition: context.scrollPosition
2009
- });
2010
- };
2011
- if (!wasReached) {
2012
- if (!within) {
2013
- return false;
2014
- }
2015
- onReached == null ? void 0 : onReached(distance);
2016
- updateSnapshot();
2017
- return true;
2018
- }
2019
- const reset = !atThreshold && threshold > 0 && absDistance >= threshold * HYSTERESIS_MULTIPLIER || !atThreshold && threshold <= 0 && absDistance > 0;
2020
- if (reset) {
2021
- setSnapshot == null ? void 0 : setSnapshot(void 0);
2022
- return false;
2023
- }
2024
- if (within) {
2025
- const changed = !snapshot || snapshot.atThreshold !== atThreshold || snapshot.contentSize !== context.contentSize || snapshot.dataLength !== context.dataLength;
2026
- if (changed) {
2027
- onReached == null ? void 0 : onReached(distance);
2028
- updateSnapshot();
2029
- }
2030
- }
2031
- return true;
2032
- };
2033
-
2034
- // src/utils/checkAtBottom.ts
2035
- function checkAtBottom(ctx, state) {
2036
- var _a3;
2037
- if (!state) {
2038
- return;
2039
- }
2040
- const {
2041
- queuedInitialLayout,
2042
- scrollLength,
2043
- scroll,
2044
- maintainingScrollAtEnd,
2045
- props: { maintainScrollAtEndThreshold, onEndReachedThreshold }
2046
- } = state;
2047
- const contentSize = getContentSize(ctx);
2048
- if (contentSize > 0 && queuedInitialLayout && !maintainingScrollAtEnd) {
2049
- const distanceFromEnd = contentSize - scroll - scrollLength;
2050
- const isContentLess = contentSize < scrollLength;
2051
- state.isAtEnd = isContentLess || distanceFromEnd < scrollLength * maintainScrollAtEndThreshold;
2052
- state.isEndReached = checkThreshold(
2053
- distanceFromEnd,
2054
- isContentLess,
2055
- onEndReachedThreshold * scrollLength,
2056
- state.isEndReached,
2057
- state.endReachedSnapshot,
2058
- {
2059
- scrollPosition: scroll,
2060
- contentSize,
2061
- dataLength: (_a3 = state.props.data) == null ? void 0 : _a3.length
2062
- },
2063
- (distance) => {
2064
- var _a4, _b;
2065
- return (_b = (_a4 = state.props).onEndReached) == null ? void 0 : _b.call(_a4, { distanceFromEnd: distance });
2066
- },
2067
- (snapshot) => {
2068
- state.endReachedSnapshot = snapshot;
2069
- }
2070
- );
2071
- }
2072
- }
2073
-
2074
2182
  // src/utils/setDidLayout.ts
2075
2183
  function setDidLayout(ctx, state) {
2076
2184
  const {
@@ -2150,7 +2258,7 @@ function handleStickyRecycling(ctx, state, stickyArray, scroll, scrollBuffer, cu
2150
2258
  const currentId = (_b = state.idCache[itemIndex]) != null ? _b : getId(state, itemIndex);
2151
2259
  if (currentId) {
2152
2260
  const currentPos = state.positions.get(currentId);
2153
- const currentSize = (_c = state.sizes.get(currentId)) != null ? _c : getItemSize(state, currentId, itemIndex, state.props.data[itemIndex]);
2261
+ const currentSize = (_c = state.sizes.get(currentId)) != null ? _c : getItemSize(ctx, state, currentId, itemIndex, state.props.data[itemIndex]);
2154
2262
  shouldRecycle = currentPos !== void 0 && scroll > currentPos + currentSize + scrollBuffer * 3;
2155
2263
  }
2156
2264
  }
@@ -2161,7 +2269,7 @@ function handleStickyRecycling(ctx, state, stickyArray, scroll, scrollBuffer, cu
2161
2269
  }
2162
2270
  function calculateItemsInView(ctx, state, params = {}) {
2163
2271
  reactDom.unstable_batchedUpdates(() => {
2164
- var _a3, _b, _c, _d, _e, _f, _g, _h, _i;
2272
+ var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j;
2165
2273
  const {
2166
2274
  columns,
2167
2275
  containerItemKeys,
@@ -2194,13 +2302,15 @@ function calculateItemsInView(ctx, state, params = {}) {
2194
2302
  let { scroll: scrollState } = state;
2195
2303
  if (!queuedInitialLayout && initialScroll) {
2196
2304
  const updatedOffset = calculateOffsetWithOffsetPosition(
2305
+ ctx,
2197
2306
  state,
2198
2307
  calculateOffsetForIndex(ctx, state, initialScroll.index),
2199
2308
  initialScroll
2200
2309
  );
2201
2310
  scrollState = updatedOffset;
2202
2311
  }
2203
- const scrollAdjustPad = -topPad;
2312
+ const scrollAdjustPending = (_a3 = peek$(ctx, "scrollAdjustPending")) != null ? _a3 : 0;
2313
+ const scrollAdjustPad = scrollAdjustPending - topPad;
2204
2314
  let scroll = scrollState + scrollExtra + scrollAdjustPad;
2205
2315
  if (scroll + scrollLength > totalSize) {
2206
2316
  scroll = Math.max(0, totalSize - scrollLength);
@@ -2213,6 +2323,7 @@ function calculateItemsInView(ctx, state, params = {}) {
2213
2323
  const currentStickyIdx = stickyIndicesArr.length > 0 ? findCurrentStickyIndex(stickyIndicesArr, scroll, state) : -1;
2214
2324
  const nextActiveStickyIndex = currentStickyIdx >= 0 ? stickyIndicesArr[currentStickyIdx] : void 0;
2215
2325
  state.activeStickyIndex = nextActiveStickyIndex;
2326
+ set$(ctx, "activeStickyIndex", nextActiveStickyIndex);
2216
2327
  let scrollBufferTop = scrollBuffer;
2217
2328
  let scrollBufferBottom = scrollBuffer;
2218
2329
  if (speed > 0 || speed === 0 && scroll < Math.max(50, scrollBuffer)) {
@@ -2237,7 +2348,7 @@ function calculateItemsInView(ctx, state, params = {}) {
2237
2348
  idCache.length = 0;
2238
2349
  positions.clear();
2239
2350
  }
2240
- const startIndex = dataChanged ? 0 : (_a3 = minIndexSizeChanged != null ? minIndexSizeChanged : state.startBuffered) != null ? _a3 : 0;
2351
+ const startIndex = dataChanged ? 0 : (_b = minIndexSizeChanged != null ? minIndexSizeChanged : state.startBuffered) != null ? _b : 0;
2241
2352
  updateItemPositions(ctx, state, dataChanged, { scrollBottomBuffered, startIndex });
2242
2353
  if (minIndexSizeChanged !== void 0) {
2243
2354
  state.minIndexSizeChanged = void 0;
@@ -2250,9 +2361,9 @@ function calculateItemsInView(ctx, state, params = {}) {
2250
2361
  let endBuffered = null;
2251
2362
  let loopStart = !dataChanged && startBufferedIdOrig ? indexByKey.get(startBufferedIdOrig) || 0 : 0;
2252
2363
  for (let i = loopStart; i >= 0; i--) {
2253
- const id = (_b = idCache[i]) != null ? _b : getId(state, i);
2364
+ const id = (_c = idCache[i]) != null ? _c : getId(state, i);
2254
2365
  const top = positions.get(id);
2255
- const size = (_c = sizes.get(id)) != null ? _c : getItemSize(state, id, i, data[i]);
2366
+ const size = (_d = sizes.get(id)) != null ? _d : getItemSize(ctx, state, id, i, data[i]);
2256
2367
  const bottom = top + size;
2257
2368
  if (bottom > scroll - scrollBuffer) {
2258
2369
  loopStart = i;
@@ -2278,8 +2389,8 @@ function calculateItemsInView(ctx, state, params = {}) {
2278
2389
  let firstFullyOnScreenIndex;
2279
2390
  const dataLength = data.length;
2280
2391
  for (let i = Math.max(0, loopStart); i < dataLength && (!foundEnd || i <= maxIndexRendered); i++) {
2281
- const id = (_d = idCache[i]) != null ? _d : getId(state, i);
2282
- const size = (_e = sizes.get(id)) != null ? _e : getItemSize(state, id, i, data[i]);
2392
+ const id = (_e = idCache[i]) != null ? _e : getId(state, i);
2393
+ const size = (_f = sizes.get(id)) != null ? _f : getItemSize(ctx, state, id, i, data[i]);
2283
2394
  const top = positions.get(id);
2284
2395
  if (!foundEnd) {
2285
2396
  if (startNoBuffer === null && top + size > scroll) {
@@ -2308,7 +2419,7 @@ function calculateItemsInView(ctx, state, params = {}) {
2308
2419
  }
2309
2420
  const idsInView = [];
2310
2421
  for (let i = firstFullyOnScreenIndex; i <= endNoBuffer; i++) {
2311
- const id = (_f = idCache[i]) != null ? _f : getId(state, i);
2422
+ const id = (_g = idCache[i]) != null ? _g : getId(state, i);
2312
2423
  idsInView.push(id);
2313
2424
  }
2314
2425
  Object.assign(state, {
@@ -2340,7 +2451,7 @@ function calculateItemsInView(ctx, state, params = {}) {
2340
2451
  let numContainers2 = prevNumContainers;
2341
2452
  const needNewContainers = [];
2342
2453
  for (let i = startBuffered; i <= endBuffered; i++) {
2343
- const id = (_g = idCache[i]) != null ? _g : getId(state, i);
2454
+ const id = (_h = idCache[i]) != null ? _h : getId(state, i);
2344
2455
  if (!containerItemKeys.has(id)) {
2345
2456
  needNewContainers.push(i);
2346
2457
  }
@@ -2358,6 +2469,7 @@ function calculateItemsInView(ctx, state, params = {}) {
2358
2469
  );
2359
2470
  } else {
2360
2471
  state.activeStickyIndex = void 0;
2472
+ set$(ctx, "activeStickyIndex", void 0);
2361
2473
  }
2362
2474
  if (needNewContainers.length > 0) {
2363
2475
  const requiredItemTypes = getItemType ? needNewContainers.map((i) => {
@@ -2377,7 +2489,7 @@ function calculateItemsInView(ctx, state, params = {}) {
2377
2489
  for (let idx = 0; idx < needNewContainers.length; idx++) {
2378
2490
  const i = needNewContainers[idx];
2379
2491
  const containerIndex = availableContainers[idx];
2380
- const id = (_h = idCache[i]) != null ? _h : getId(state, i);
2492
+ const id = (_i = idCache[i]) != null ? _i : getId(state, i);
2381
2493
  const oldKey = peek$(ctx, `containerItemKey${containerIndex}`);
2382
2494
  if (oldKey && oldKey !== id) {
2383
2495
  containerItemKeys.delete(oldKey);
@@ -2433,11 +2545,12 @@ function calculateItemsInView(ctx, state, params = {}) {
2433
2545
  const itemIndex = indexByKey.get(itemKey);
2434
2546
  const item = data[itemIndex];
2435
2547
  if (item !== void 0) {
2436
- const id = (_i = idCache[itemIndex]) != null ? _i : getId(state, itemIndex);
2437
- const position = positions.get(id);
2438
- if (position === void 0) {
2548
+ const id = (_j = idCache[itemIndex]) != null ? _j : getId(state, itemIndex);
2549
+ const positionValue = positions.get(id);
2550
+ if (positionValue === void 0) {
2439
2551
  set$(ctx, `containerPosition${i}`, POSITION_OUT_OF_VIEW);
2440
2552
  } else {
2553
+ const position = (positionValue || 0) - scrollAdjustPending;
2441
2554
  const column = columns.get(id) || 1;
2442
2555
  const prevPos = peek$(ctx, `containerPosition${i}`);
2443
2556
  const prevColumn = peek$(ctx, `containerColumn${i}`);
@@ -2506,40 +2619,6 @@ function doMaintainScrollAtEnd(ctx, state, animated) {
2506
2619
  }
2507
2620
  }
2508
2621
 
2509
- // src/utils/checkAtTop.ts
2510
- function checkAtTop(state) {
2511
- var _a3;
2512
- if (!state) {
2513
- return;
2514
- }
2515
- const {
2516
- scrollLength,
2517
- scroll,
2518
- props: { onStartReachedThreshold }
2519
- } = state;
2520
- const distanceFromTop = scroll;
2521
- state.isAtStart = distanceFromTop <= 0;
2522
- state.isStartReached = checkThreshold(
2523
- distanceFromTop,
2524
- false,
2525
- onStartReachedThreshold * scrollLength,
2526
- state.isStartReached,
2527
- state.startReachedSnapshot,
2528
- {
2529
- scrollPosition: scroll,
2530
- contentSize: state.totalSize,
2531
- dataLength: (_a3 = state.props.data) == null ? void 0 : _a3.length
2532
- },
2533
- (distance) => {
2534
- var _a4, _b;
2535
- return (_b = (_a4 = state.props).onStartReached) == null ? void 0 : _b.call(_a4, { distanceFromStart: distance });
2536
- },
2537
- (snapshot) => {
2538
- state.startReachedSnapshot = snapshot;
2539
- }
2540
- );
2541
- }
2542
-
2543
2622
  // src/utils/updateAveragesOnDataChange.ts
2544
2623
  function updateAveragesOnDataChange(state, oldData, newData) {
2545
2624
  var _a3;
@@ -2708,78 +2787,47 @@ function handleLayout(ctx, state, layout, setCanRender) {
2708
2787
  setCanRender(true);
2709
2788
  }
2710
2789
 
2711
- // src/core/onScroll.ts
2712
- function onScroll(ctx, state, event) {
2713
- var _a3, _b, _c;
2714
- const {
2715
- scrollProcessingEnabled,
2716
- props: { onScroll: onScrollProp }
2717
- } = state;
2718
- if (scrollProcessingEnabled === false) {
2719
- return;
2720
- }
2721
- 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) {
2722
- return;
2723
- }
2724
- const newScroll = event.nativeEvent.contentOffset[state.props.horizontal ? "x" : "y"];
2725
- state.scrollPending = newScroll;
2726
- updateScroll(ctx, state, newScroll);
2727
- onScrollProp == null ? void 0 : onScrollProp(event);
2728
- }
2729
- function updateScroll(ctx, state, newScroll) {
2730
- const scrollingTo = state.scrollingTo;
2731
- state.hasScrolled = true;
2732
- state.lastBatchingAction = Date.now();
2733
- const currentTime = Date.now();
2734
- const adjust = state.scrollAdjustHandler.getAdjust();
2735
- const lastHistoryAdjust = state.lastScrollAdjustForHistory;
2736
- const adjustChanged = lastHistoryAdjust !== void 0 && Math.abs(adjust - lastHistoryAdjust) > 0.1;
2737
- if (adjustChanged) {
2738
- state.scrollHistory.length = 0;
2739
- }
2740
- state.lastScrollAdjustForHistory = adjust;
2741
- if (scrollingTo === void 0 && !(state.scrollHistory.length === 0 && newScroll === state.scroll)) {
2742
- if (!adjustChanged) {
2743
- state.scrollHistory.push({ scroll: newScroll, time: currentTime });
2744
- }
2745
- }
2746
- if (state.scrollHistory.length > 5) {
2747
- state.scrollHistory.shift();
2748
- }
2749
- state.scrollPrev = state.scroll;
2750
- state.scrollPrevTime = state.scrollTime;
2751
- state.scroll = newScroll;
2752
- state.scrollTime = currentTime;
2753
- const ignoreScrollFromMVCP = state.ignoreScrollFromMVCP;
2754
- if (ignoreScrollFromMVCP && !state.scrollingTo) {
2755
- const { lt, gt } = ignoreScrollFromMVCP;
2756
- if (lt && newScroll < lt || gt && newScroll > gt) {
2757
- return;
2758
- }
2759
- }
2760
- if (state.dataChangeNeedsScrollUpdate || Math.abs(state.scroll - state.scrollPrev) > 2) {
2761
- calculateItemsInView(ctx, state, { doMVCP: state.scrollingTo !== void 0 });
2762
- checkAtBottom(ctx, state);
2763
- checkAtTop(state);
2764
- state.dataChangeNeedsScrollUpdate = false;
2765
- }
2766
- }
2767
-
2768
2790
  // src/core/ScrollAdjustHandler.ts
2769
2791
  var ScrollAdjustHandler = class {
2770
2792
  constructor(ctx) {
2771
2793
  this.appliedAdjust = 0;
2794
+ this.pendingAdjust = 0;
2772
2795
  this.mounted = false;
2773
2796
  this.context = ctx;
2797
+ {
2798
+ const commitPendingAdjust = () => {
2799
+ const state = this.context.internalState;
2800
+ const pending = this.pendingAdjust;
2801
+ if (pending !== 0) {
2802
+ this.pendingAdjust = 0;
2803
+ this.appliedAdjust += pending;
2804
+ state.scroll += pending;
2805
+ state.scrollForNextCalculateItemsInView = void 0;
2806
+ set$(this.context, "scrollAdjustPending", 0);
2807
+ set$(this.context, "scrollAdjust", this.appliedAdjust);
2808
+ calculateItemsInView(this.context, this.context.internalState);
2809
+ }
2810
+ };
2811
+ listen$(this.context, "scrollingTo", (value) => {
2812
+ if (value === void 0) {
2813
+ commitPendingAdjust();
2814
+ }
2815
+ });
2816
+ }
2774
2817
  }
2775
2818
  requestAdjust(add) {
2776
- const oldAdjustTop = this.appliedAdjust;
2777
- this.appliedAdjust = add + oldAdjustTop;
2778
- const set = () => set$(this.context, "scrollAdjust", this.appliedAdjust);
2779
- if (this.mounted) {
2780
- set();
2819
+ const scrollingTo = peek$(this.context, "scrollingTo");
2820
+ if ((scrollingTo == null ? void 0 : scrollingTo.animated) && !scrollingTo.isInitialScroll) {
2821
+ this.pendingAdjust += add;
2822
+ set$(this.context, "scrollAdjustPending", this.pendingAdjust);
2781
2823
  } else {
2782
- requestAnimationFrame(set);
2824
+ this.appliedAdjust += add;
2825
+ const setter = () => set$(this.context, "scrollAdjust", this.appliedAdjust);
2826
+ if (this.mounted) {
2827
+ setter();
2828
+ } else {
2829
+ requestAnimationFrame(setter);
2830
+ }
2783
2831
  }
2784
2832
  }
2785
2833
  setMounted() {
@@ -2827,7 +2875,7 @@ function updateItemSize(ctx, state, itemKey, sizeObj) {
2827
2875
  let minIndexSizeChanged;
2828
2876
  let maxOtherAxisSize = peek$(ctx, "otherAxisSize") || 0;
2829
2877
  const prevSizeKnown = state.sizesKnown.get(itemKey);
2830
- const diff = updateOneItemSize(state, itemKey, sizeObj);
2878
+ const diff = updateOneItemSize(ctx, state, itemKey, sizeObj);
2831
2879
  const size = Math.floor((horizontal ? sizeObj.width : sizeObj.height) * 8) / 8;
2832
2880
  if (diff !== 0) {
2833
2881
  minIndexSizeChanged = minIndexSizeChanged !== void 0 ? Math.min(minIndexSizeChanged, index) : index;
@@ -2889,7 +2937,7 @@ function updateItemSize(ctx, state, itemKey, sizeObj) {
2889
2937
  }
2890
2938
  }
2891
2939
  }
2892
- function updateOneItemSize(state, itemKey, sizeObj) {
2940
+ function updateOneItemSize(ctx, state, itemKey, sizeObj) {
2893
2941
  var _a3;
2894
2942
  const {
2895
2943
  sizes,
@@ -2900,7 +2948,7 @@ function updateOneItemSize(state, itemKey, sizeObj) {
2900
2948
  } = state;
2901
2949
  if (!data) return 0;
2902
2950
  const index = indexByKey.get(itemKey);
2903
- const prevSize = getItemSize(state, itemKey, index, data[index]);
2951
+ const prevSize = getItemSize(ctx, state, itemKey, index, data[index]);
2904
2952
  const rawSize = horizontal ? sizeObj.width : sizeObj.height;
2905
2953
  const size = Math.round(rawSize) ;
2906
2954
  sizesKnown.set(itemKey, size);
@@ -3108,7 +3156,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3108
3156
  ...rest
3109
3157
  } = props;
3110
3158
  const [renderNum, setRenderNum] = React3.useState(0);
3111
- const initialScroll = initialScrollIndexProp || initialScrollOffsetProp ? typeof initialScrollIndexProp === "object" ? { index: initialScrollIndexProp.index || 0, viewOffset: initialScrollIndexProp.viewOffset || 0 } : { index: initialScrollIndexProp || 0, viewOffset: initialScrollOffsetProp || 0 } : void 0;
3159
+ const initialScrollProp = initialScrollIndexProp || initialScrollOffsetProp ? typeof initialScrollIndexProp === "object" ? { index: initialScrollIndexProp.index || 0, viewOffset: initialScrollIndexProp.viewOffset || 0 } : { index: initialScrollIndexProp || 0, viewOffset: initialScrollOffsetProp || 0 } : void 0;
3112
3160
  const [canRender, setCanRender] = React3__namespace.useState(!IsNewArchitecture);
3113
3161
  const contentContainerStyle = { ...StyleSheet.flatten(contentContainerStyleProp) };
3114
3162
  const style = { ...StyleSheet.flatten(styleProp) };
@@ -3140,7 +3188,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3140
3188
  idCache: [],
3141
3189
  idsInView: [],
3142
3190
  indexByKey: /* @__PURE__ */ new Map(),
3143
- initialScroll,
3191
+ initialScroll: initialScrollProp,
3144
3192
  isAtEnd: false,
3145
3193
  isAtStart: false,
3146
3194
  isEndReached: false,
@@ -3198,7 +3246,6 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3198
3246
  getItemType,
3199
3247
  horizontal: !!horizontal,
3200
3248
  initialContainerPoolRatio,
3201
- initialScroll,
3202
3249
  itemsAreEqual,
3203
3250
  keyExtractor,
3204
3251
  maintainScrollAtEnd,
@@ -3255,6 +3302,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3255
3302
  );
3256
3303
  }
3257
3304
  const initialContentOffset = React3.useMemo(() => {
3305
+ const { initialScroll } = refState.current;
3258
3306
  if (initialScroll) {
3259
3307
  const { index, viewOffset } = initialScroll;
3260
3308
  let initialContentOffset2 = viewOffset || 0;
@@ -3263,7 +3311,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3263
3311
  }
3264
3312
  refState.current.isStartReached = initialContentOffset2 < refState.current.scrollLength * onStartReachedThreshold;
3265
3313
  if (initialContentOffset2 > 0) {
3266
- scrollTo(state, {
3314
+ scrollTo(ctx, state, {
3267
3315
  animated: false,
3268
3316
  index,
3269
3317
  isInitialScroll: true,
@@ -3287,6 +3335,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3287
3335
  }
3288
3336
  }
3289
3337
  const onLayoutHeader = React3.useCallback((rect, fromLayoutEffect) => {
3338
+ const { initialScroll } = refState.current;
3290
3339
  const size = rect[horizontal ? "width" : "height"];
3291
3340
  set$(ctx, "headerSize", size);
3292
3341
  if ((initialScroll == null ? void 0 : initialScroll.index) !== void 0) {
@@ -3413,7 +3462,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3413
3462
  scrollToIndex(ctx, state, { index, ...props2 });
3414
3463
  }
3415
3464
  },
3416
- scrollToOffset: (params) => scrollTo(state, params),
3465
+ scrollToOffset: (params) => scrollTo(ctx, state, params),
3417
3466
  setScrollProcessingEnabled: (enabled) => {
3418
3467
  refState.current.scrollProcessingEnabled = enabled;
3419
3468
  },
@@ -3425,8 +3474,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3425
3474
  }, []);
3426
3475
  {
3427
3476
  React3.useEffect(() => {
3477
+ const { initialScroll } = refState.current;
3428
3478
  if (initialContentOffset) {
3429
- scrollTo(state, { animated: false, offset: initialContentOffset, ...initialScroll || {} });
3479
+ scrollTo(ctx, state, { animated: false, offset: initialContentOffset, ...initialScroll || {} });
3430
3480
  }
3431
3481
  }, []);
3432
3482
  }
@@ -3457,7 +3507,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3457
3507
  onMomentumScrollEnd: (event) => {
3458
3508
  {
3459
3509
  requestAnimationFrame(() => {
3460
- finishScrollTo(refState.current);
3510
+ finishScrollTo(ctx, refState.current);
3461
3511
  });
3462
3512
  }
3463
3513
  if (onMomentumScrollEnd) {