@legendapp/list 3.0.0-beta.10 → 3.0.0-beta.12

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/section-list.js CHANGED
@@ -365,9 +365,20 @@ var IsNewArchitecture = true;
365
365
 
366
366
  // src/state/ContextContainer.ts
367
367
  var ContextContainer = React3.createContext(null);
368
+ function useContextContainer() {
369
+ return React3.useContext(ContextContainer);
370
+ }
368
371
  function useIsLastItem() {
369
- const { itemKey } = React3.useContext(ContextContainer);
370
- const isLast = useSelector$("lastItemKeys", (lastItemKeys) => (lastItemKeys == null ? void 0 : lastItemKeys.includes(itemKey)) || false);
372
+ const containerContext = useContextContainer();
373
+ const isLast = useSelector$("lastItemKeys", (lastItemKeys) => {
374
+ if (containerContext) {
375
+ const { itemKey } = containerContext;
376
+ if (!isNullOrUndefined(itemKey)) {
377
+ return (lastItemKeys == null ? void 0 : lastItemKeys.includes(itemKey)) || false;
378
+ }
379
+ }
380
+ return false;
381
+ });
371
382
  return isLast;
372
383
  }
373
384
 
@@ -1012,9 +1023,6 @@ function ScrollAdjust() {
1012
1023
  } else {
1013
1024
  scrollView.scrollBy(0, scrollDelta);
1014
1025
  }
1015
- if (IS_DEV) {
1016
- console.log("ScrollAdjust (web scrollBy)", scrollDelta, "total offset:", scrollOffset);
1017
- }
1018
1026
  }
1019
1027
  lastScrollOffsetRef.current = scrollOffset;
1020
1028
  }
@@ -1063,7 +1071,6 @@ var ListComponent = typedMemo(function ListComponent2({
1063
1071
  getRenderedItem: getRenderedItem2,
1064
1072
  updateItemSize: updateItemSize2,
1065
1073
  refScrollView,
1066
- maintainVisibleContentPosition,
1067
1074
  renderScrollComponent,
1068
1075
  scrollAdjustHandler,
1069
1076
  onLayoutHeader,
@@ -1072,6 +1079,7 @@ var ListComponent = typedMemo(function ListComponent2({
1072
1079
  ...rest
1073
1080
  }) {
1074
1081
  const ctx = useStateContext();
1082
+ const maintainVisibleContentPosition = ctx.state.props.maintainVisibleContentPosition;
1075
1083
  const ScrollComponent = renderScrollComponent ? React3.useMemo(
1076
1084
  () => React3__namespace.forwardRef((props, ref) => renderScrollComponent({ ...props, ref })),
1077
1085
  [renderScrollComponent]
@@ -1089,7 +1097,7 @@ var ListComponent = typedMemo(function ListComponent2({
1089
1097
  ],
1090
1098
  contentOffset: initialContentOffset ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
1091
1099
  horizontal,
1092
- maintainVisibleContentPosition: maintainVisibleContentPosition ? { minIndexForVisible: 0 } : void 0,
1100
+ maintainVisibleContentPosition: maintainVisibleContentPosition.scroll || maintainVisibleContentPosition.dataChanges ? { minIndexForVisible: 0 } : void 0,
1093
1101
  onLayout,
1094
1102
  onScroll: onScroll2,
1095
1103
  ref: refScrollView,
@@ -1633,14 +1641,16 @@ function requestAdjust(ctx, positionDiff, dataChanged) {
1633
1641
  function prepareMVCP(ctx, dataChanged) {
1634
1642
  const state = ctx.state;
1635
1643
  const { idsInView, positions, props } = state;
1636
- const { maintainVisibleContentPosition } = props;
1644
+ const {
1645
+ maintainVisibleContentPosition: { dataChanges: mvcpDataChanges, scroll: mvcpScroll }
1646
+ } = props;
1637
1647
  const scrollingTo = state.scrollingTo;
1638
1648
  let prevPosition;
1639
1649
  let targetId;
1640
1650
  const idsInViewWithPositions = [];
1641
1651
  const scrollTarget = scrollingTo == null ? void 0 : scrollingTo.index;
1642
1652
  const scrollingToViewPosition = scrollingTo == null ? void 0 : scrollingTo.viewPosition;
1643
- const shouldMVCP = !dataChanged || maintainVisibleContentPosition;
1653
+ const shouldMVCP = dataChanged ? mvcpDataChanges : mvcpScroll;
1644
1654
  const indexByKey = state.indexByKey;
1645
1655
  if (shouldMVCP) {
1646
1656
  if (scrollTarget !== void 0) {
@@ -1663,7 +1673,7 @@ function prepareMVCP(ctx, dataChanged) {
1663
1673
  }
1664
1674
  return () => {
1665
1675
  let positionDiff = 0;
1666
- if (dataChanged && targetId === void 0 && maintainVisibleContentPosition) {
1676
+ if (dataChanged && targetId === void 0 && mvcpDataChanges) {
1667
1677
  for (let i = 0; i < idsInViewWithPositions.length; i++) {
1668
1678
  const { id, position } = idsInViewWithPositions[i];
1669
1679
  const newPosition = positions.get(id);
@@ -1797,39 +1807,40 @@ function updateTotalSize(ctx) {
1797
1807
  // src/utils/getScrollVelocity.ts
1798
1808
  var getScrollVelocity = (state) => {
1799
1809
  const { scrollHistory } = state;
1800
- let velocity = 0;
1801
- if (scrollHistory.length >= 1) {
1802
- const newest = scrollHistory[scrollHistory.length - 1];
1803
- let oldest;
1804
- let start = 0;
1805
- const now = Date.now();
1806
- for (let i = 0; i < scrollHistory.length - 1; i++) {
1807
- const entry = scrollHistory[i];
1808
- const nextEntry = scrollHistory[i + 1];
1809
- if (i > 0) {
1810
- const prevEntry = scrollHistory[i - 1];
1811
- const prevDirection = entry.scroll - prevEntry.scroll;
1812
- const currentDirection = nextEntry.scroll - entry.scroll;
1813
- if (prevDirection > 0 && currentDirection < 0 || prevDirection < 0 && currentDirection > 0) {
1814
- start = i;
1815
- break;
1816
- }
1817
- }
1810
+ const newestIndex = scrollHistory.length - 1;
1811
+ if (newestIndex < 1) {
1812
+ return 0;
1813
+ }
1814
+ const newest = scrollHistory[newestIndex];
1815
+ const now = Date.now();
1816
+ let direction = 0;
1817
+ for (let i = newestIndex; i > 0; i--) {
1818
+ const delta = scrollHistory[i].scroll - scrollHistory[i - 1].scroll;
1819
+ if (delta !== 0) {
1820
+ direction = Math.sign(delta);
1821
+ break;
1818
1822
  }
1819
- for (let i = start; i < scrollHistory.length - 1; i++) {
1820
- const entry = scrollHistory[i];
1821
- if (now - entry.time <= 1e3) {
1822
- oldest = entry;
1823
- break;
1824
- }
1823
+ }
1824
+ if (direction === 0) {
1825
+ return 0;
1826
+ }
1827
+ let oldest = newest;
1828
+ for (let i = newestIndex - 1; i >= 0; i--) {
1829
+ const current = scrollHistory[i];
1830
+ const next = scrollHistory[i + 1];
1831
+ const delta = next.scroll - current.scroll;
1832
+ const deltaSign = Math.sign(delta);
1833
+ if (deltaSign !== 0 && deltaSign !== direction) {
1834
+ break;
1825
1835
  }
1826
- if (oldest && oldest !== newest) {
1827
- const scrollDiff = newest.scroll - oldest.scroll;
1828
- const timeDiff = newest.time - oldest.time;
1829
- velocity = timeDiff > 0 ? scrollDiff / timeDiff : 0;
1836
+ if (now - current.time > 1e3) {
1837
+ break;
1830
1838
  }
1839
+ oldest = current;
1831
1840
  }
1832
- return velocity;
1841
+ const scrollDiff = newest.scroll - oldest.scroll;
1842
+ const timeDiff = newest.time - oldest.time;
1843
+ return timeDiff > 0 ? scrollDiff / timeDiff : 0;
1833
1844
  };
1834
1845
 
1835
1846
  // src/utils/updateSnapToOffsets.ts
@@ -2759,7 +2770,7 @@ function checkFinishedScrollFrame(ctx) {
2759
2770
  if (scrollingTo) {
2760
2771
  const { state } = ctx;
2761
2772
  state.animFrameCheckFinishedScroll = void 0;
2762
- const scroll = state.scroll;
2773
+ const scroll = state.scrollPending;
2763
2774
  const adjust = state.scrollAdjustHandler.getAdjust();
2764
2775
  const clampedTargetOffset = clampScrollOffset(ctx, scrollingTo.offset - (scrollingTo.viewOffset || 0));
2765
2776
  const maxOffset = clampScrollOffset(ctx, scroll);
@@ -3014,7 +3025,6 @@ function onScroll(ctx, event) {
3014
3025
  return;
3015
3026
  }
3016
3027
  let newScroll = event.nativeEvent.contentOffset[state.props.horizontal ? "x" : "y"];
3017
- state.scrollPending = newScroll;
3018
3028
  if (state.scrollingTo) {
3019
3029
  const maxOffset = clampScrollOffset(ctx, newScroll);
3020
3030
  if (newScroll !== maxOffset && Math.abs(newScroll - maxOffset) > 1) {
@@ -3028,8 +3038,11 @@ function onScroll(ctx, event) {
3028
3038
  return;
3029
3039
  }
3030
3040
  }
3041
+ state.scrollPending = newScroll;
3031
3042
  updateScroll(ctx, newScroll);
3032
- checkFinishedScroll(ctx);
3043
+ if (state.scrollingTo) {
3044
+ checkFinishedScroll(ctx);
3045
+ }
3033
3046
  onScrollProp == null ? void 0 : onScrollProp(event);
3034
3047
  }
3035
3048
 
@@ -3364,6 +3377,24 @@ function getRenderedItem(ctx, key) {
3364
3377
  }
3365
3378
  return { index, item: data[index], renderedItem };
3366
3379
  }
3380
+
3381
+ // src/utils/normalizeMaintainVisibleContentPosition.ts
3382
+ function normalizeMaintainVisibleContentPosition(value) {
3383
+ var _a3, _b;
3384
+ if (value === true) {
3385
+ return { dataChanges: true, scroll: true };
3386
+ }
3387
+ if (value && typeof value === "object") {
3388
+ return {
3389
+ dataChanges: (_a3 = value.dataChanges) != null ? _a3 : false,
3390
+ scroll: (_b = value.scroll) != null ? _b : true
3391
+ };
3392
+ }
3393
+ if (value === false) {
3394
+ return { dataChanges: false, scroll: false };
3395
+ }
3396
+ return { dataChanges: false, scroll: true };
3397
+ }
3367
3398
  function useThrottleDebounce(mode) {
3368
3399
  const timeoutRef = React3.useRef(null);
3369
3400
  const lastCallTimeRef = React3.useRef(0);
@@ -3458,7 +3489,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3458
3489
  ListHeaderComponent,
3459
3490
  maintainScrollAtEnd = false,
3460
3491
  maintainScrollAtEndThreshold = 0.1,
3461
- maintainVisibleContentPosition = false,
3492
+ maintainVisibleContentPosition: maintainVisibleContentPositionProp,
3462
3493
  numColumns: numColumnsProp = 1,
3463
3494
  onEndReached,
3464
3495
  onEndReachedThreshold = 0.5,
@@ -3496,6 +3527,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3496
3527
  const style = { ...StyleSheet.flatten(styleProp) };
3497
3528
  const stylePaddingTopState = extractPadding(style, contentContainerStyle, "Top");
3498
3529
  const stylePaddingBottomState = extractPadding(style, contentContainerStyle, "Bottom");
3530
+ const maintainVisibleContentPositionConfig = normalizeMaintainVisibleContentPosition(
3531
+ maintainVisibleContentPositionProp
3532
+ );
3499
3533
  const [renderNum, setRenderNum] = React3.useState(0);
3500
3534
  const initialScrollProp = initialScrollAtEnd ? { index: Math.max(0, dataProp.length - 1), viewOffset: -stylePaddingBottomState } : initialScrollIndexProp || initialScrollOffsetProp ? typeof initialScrollIndexProp === "object" ? { index: initialScrollIndexProp.index || 0, viewOffset: initialScrollIndexProp.viewOffset || 0 } : { index: initialScrollIndexProp || 0, viewOffset: initialScrollOffsetProp || 0 } : void 0;
3501
3535
  const [canRender, setCanRender] = React3__namespace.useState(!IsNewArchitecture);
@@ -3580,7 +3614,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3580
3614
  };
3581
3615
  const internalState = ctx.state;
3582
3616
  internalState.triggerCalculateItemsInView = (params) => calculateItemsInView(ctx, params);
3583
- set$(ctx, "maintainVisibleContentPosition", maintainVisibleContentPosition);
3617
+ set$(ctx, "maintainVisibleContentPosition", maintainVisibleContentPositionConfig);
3584
3618
  set$(ctx, "extraData", extraData);
3585
3619
  }
3586
3620
  refState.current = ctx.state;
@@ -3611,7 +3645,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3611
3645
  keyExtractor,
3612
3646
  maintainScrollAtEnd,
3613
3647
  maintainScrollAtEndThreshold,
3614
- maintainVisibleContentPosition,
3648
+ maintainVisibleContentPosition: maintainVisibleContentPositionConfig,
3615
3649
  numColumns: numColumnsProp,
3616
3650
  onEndReached,
3617
3651
  onEndReachedThreshold,
@@ -3646,7 +3680,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3646
3680
  setPaddingTop(ctx, { stylePaddingTop: stylePaddingTopState });
3647
3681
  refState.current.props.stylePaddingBottom = stylePaddingBottomState;
3648
3682
  let paddingDiff = stylePaddingTopState - prevPaddingTop;
3649
- if (paddingDiff && prevPaddingTop !== void 0 && Platform.OS === "ios") {
3683
+ if (maintainVisibleContentPositionConfig.scroll && paddingDiff && prevPaddingTop !== void 0 && Platform.OS === "ios") {
3650
3684
  if (state.scroll < 0) {
3651
3685
  paddingDiff += state.scroll;
3652
3686
  }
@@ -3681,7 +3715,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3681
3715
  value = 0;
3682
3716
  }
3683
3717
  if (!value) {
3684
- state.didFinishInitialScroll = true;
3718
+ setInitialRenderState(ctx, { didInitialScroll: true });
3685
3719
  }
3686
3720
  return value;
3687
3721
  }, [renderNum]);
@@ -3803,7 +3837,6 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3803
3837
  initialContentOffset,
3804
3838
  ListEmptyComponent: dataProp.length === 0 ? ListEmptyComponent : void 0,
3805
3839
  ListHeaderComponent,
3806
- maintainVisibleContentPosition,
3807
3840
  onLayout,
3808
3841
  onLayoutHeader,
3809
3842
  onMomentumScrollEnd: fns.onMomentumScrollEnd,
package/section-list.mjs CHANGED
@@ -344,9 +344,20 @@ var IsNewArchitecture = true;
344
344
 
345
345
  // src/state/ContextContainer.ts
346
346
  var ContextContainer = createContext(null);
347
+ function useContextContainer() {
348
+ return useContext(ContextContainer);
349
+ }
347
350
  function useIsLastItem() {
348
- const { itemKey } = useContext(ContextContainer);
349
- const isLast = useSelector$("lastItemKeys", (lastItemKeys) => (lastItemKeys == null ? void 0 : lastItemKeys.includes(itemKey)) || false);
351
+ const containerContext = useContextContainer();
352
+ const isLast = useSelector$("lastItemKeys", (lastItemKeys) => {
353
+ if (containerContext) {
354
+ const { itemKey } = containerContext;
355
+ if (!isNullOrUndefined(itemKey)) {
356
+ return (lastItemKeys == null ? void 0 : lastItemKeys.includes(itemKey)) || false;
357
+ }
358
+ }
359
+ return false;
360
+ });
350
361
  return isLast;
351
362
  }
352
363
 
@@ -991,9 +1002,6 @@ function ScrollAdjust() {
991
1002
  } else {
992
1003
  scrollView.scrollBy(0, scrollDelta);
993
1004
  }
994
- if (IS_DEV) {
995
- console.log("ScrollAdjust (web scrollBy)", scrollDelta, "total offset:", scrollOffset);
996
- }
997
1005
  }
998
1006
  lastScrollOffsetRef.current = scrollOffset;
999
1007
  }
@@ -1042,7 +1050,6 @@ var ListComponent = typedMemo(function ListComponent2({
1042
1050
  getRenderedItem: getRenderedItem2,
1043
1051
  updateItemSize: updateItemSize2,
1044
1052
  refScrollView,
1045
- maintainVisibleContentPosition,
1046
1053
  renderScrollComponent,
1047
1054
  scrollAdjustHandler,
1048
1055
  onLayoutHeader,
@@ -1051,6 +1058,7 @@ var ListComponent = typedMemo(function ListComponent2({
1051
1058
  ...rest
1052
1059
  }) {
1053
1060
  const ctx = useStateContext();
1061
+ const maintainVisibleContentPosition = ctx.state.props.maintainVisibleContentPosition;
1054
1062
  const ScrollComponent = renderScrollComponent ? useMemo(
1055
1063
  () => React3.forwardRef((props, ref) => renderScrollComponent({ ...props, ref })),
1056
1064
  [renderScrollComponent]
@@ -1068,7 +1076,7 @@ var ListComponent = typedMemo(function ListComponent2({
1068
1076
  ],
1069
1077
  contentOffset: initialContentOffset ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
1070
1078
  horizontal,
1071
- maintainVisibleContentPosition: maintainVisibleContentPosition ? { minIndexForVisible: 0 } : void 0,
1079
+ maintainVisibleContentPosition: maintainVisibleContentPosition.scroll || maintainVisibleContentPosition.dataChanges ? { minIndexForVisible: 0 } : void 0,
1072
1080
  onLayout,
1073
1081
  onScroll: onScroll2,
1074
1082
  ref: refScrollView,
@@ -1612,14 +1620,16 @@ function requestAdjust(ctx, positionDiff, dataChanged) {
1612
1620
  function prepareMVCP(ctx, dataChanged) {
1613
1621
  const state = ctx.state;
1614
1622
  const { idsInView, positions, props } = state;
1615
- const { maintainVisibleContentPosition } = props;
1623
+ const {
1624
+ maintainVisibleContentPosition: { dataChanges: mvcpDataChanges, scroll: mvcpScroll }
1625
+ } = props;
1616
1626
  const scrollingTo = state.scrollingTo;
1617
1627
  let prevPosition;
1618
1628
  let targetId;
1619
1629
  const idsInViewWithPositions = [];
1620
1630
  const scrollTarget = scrollingTo == null ? void 0 : scrollingTo.index;
1621
1631
  const scrollingToViewPosition = scrollingTo == null ? void 0 : scrollingTo.viewPosition;
1622
- const shouldMVCP = !dataChanged || maintainVisibleContentPosition;
1632
+ const shouldMVCP = dataChanged ? mvcpDataChanges : mvcpScroll;
1623
1633
  const indexByKey = state.indexByKey;
1624
1634
  if (shouldMVCP) {
1625
1635
  if (scrollTarget !== void 0) {
@@ -1642,7 +1652,7 @@ function prepareMVCP(ctx, dataChanged) {
1642
1652
  }
1643
1653
  return () => {
1644
1654
  let positionDiff = 0;
1645
- if (dataChanged && targetId === void 0 && maintainVisibleContentPosition) {
1655
+ if (dataChanged && targetId === void 0 && mvcpDataChanges) {
1646
1656
  for (let i = 0; i < idsInViewWithPositions.length; i++) {
1647
1657
  const { id, position } = idsInViewWithPositions[i];
1648
1658
  const newPosition = positions.get(id);
@@ -1776,39 +1786,40 @@ function updateTotalSize(ctx) {
1776
1786
  // src/utils/getScrollVelocity.ts
1777
1787
  var getScrollVelocity = (state) => {
1778
1788
  const { scrollHistory } = state;
1779
- let velocity = 0;
1780
- if (scrollHistory.length >= 1) {
1781
- const newest = scrollHistory[scrollHistory.length - 1];
1782
- let oldest;
1783
- let start = 0;
1784
- const now = Date.now();
1785
- for (let i = 0; i < scrollHistory.length - 1; i++) {
1786
- const entry = scrollHistory[i];
1787
- const nextEntry = scrollHistory[i + 1];
1788
- if (i > 0) {
1789
- const prevEntry = scrollHistory[i - 1];
1790
- const prevDirection = entry.scroll - prevEntry.scroll;
1791
- const currentDirection = nextEntry.scroll - entry.scroll;
1792
- if (prevDirection > 0 && currentDirection < 0 || prevDirection < 0 && currentDirection > 0) {
1793
- start = i;
1794
- break;
1795
- }
1796
- }
1789
+ const newestIndex = scrollHistory.length - 1;
1790
+ if (newestIndex < 1) {
1791
+ return 0;
1792
+ }
1793
+ const newest = scrollHistory[newestIndex];
1794
+ const now = Date.now();
1795
+ let direction = 0;
1796
+ for (let i = newestIndex; i > 0; i--) {
1797
+ const delta = scrollHistory[i].scroll - scrollHistory[i - 1].scroll;
1798
+ if (delta !== 0) {
1799
+ direction = Math.sign(delta);
1800
+ break;
1797
1801
  }
1798
- for (let i = start; i < scrollHistory.length - 1; i++) {
1799
- const entry = scrollHistory[i];
1800
- if (now - entry.time <= 1e3) {
1801
- oldest = entry;
1802
- break;
1803
- }
1802
+ }
1803
+ if (direction === 0) {
1804
+ return 0;
1805
+ }
1806
+ let oldest = newest;
1807
+ for (let i = newestIndex - 1; i >= 0; i--) {
1808
+ const current = scrollHistory[i];
1809
+ const next = scrollHistory[i + 1];
1810
+ const delta = next.scroll - current.scroll;
1811
+ const deltaSign = Math.sign(delta);
1812
+ if (deltaSign !== 0 && deltaSign !== direction) {
1813
+ break;
1804
1814
  }
1805
- if (oldest && oldest !== newest) {
1806
- const scrollDiff = newest.scroll - oldest.scroll;
1807
- const timeDiff = newest.time - oldest.time;
1808
- velocity = timeDiff > 0 ? scrollDiff / timeDiff : 0;
1815
+ if (now - current.time > 1e3) {
1816
+ break;
1809
1817
  }
1818
+ oldest = current;
1810
1819
  }
1811
- return velocity;
1820
+ const scrollDiff = newest.scroll - oldest.scroll;
1821
+ const timeDiff = newest.time - oldest.time;
1822
+ return timeDiff > 0 ? scrollDiff / timeDiff : 0;
1812
1823
  };
1813
1824
 
1814
1825
  // src/utils/updateSnapToOffsets.ts
@@ -2738,7 +2749,7 @@ function checkFinishedScrollFrame(ctx) {
2738
2749
  if (scrollingTo) {
2739
2750
  const { state } = ctx;
2740
2751
  state.animFrameCheckFinishedScroll = void 0;
2741
- const scroll = state.scroll;
2752
+ const scroll = state.scrollPending;
2742
2753
  const adjust = state.scrollAdjustHandler.getAdjust();
2743
2754
  const clampedTargetOffset = clampScrollOffset(ctx, scrollingTo.offset - (scrollingTo.viewOffset || 0));
2744
2755
  const maxOffset = clampScrollOffset(ctx, scroll);
@@ -2993,7 +3004,6 @@ function onScroll(ctx, event) {
2993
3004
  return;
2994
3005
  }
2995
3006
  let newScroll = event.nativeEvent.contentOffset[state.props.horizontal ? "x" : "y"];
2996
- state.scrollPending = newScroll;
2997
3007
  if (state.scrollingTo) {
2998
3008
  const maxOffset = clampScrollOffset(ctx, newScroll);
2999
3009
  if (newScroll !== maxOffset && Math.abs(newScroll - maxOffset) > 1) {
@@ -3007,8 +3017,11 @@ function onScroll(ctx, event) {
3007
3017
  return;
3008
3018
  }
3009
3019
  }
3020
+ state.scrollPending = newScroll;
3010
3021
  updateScroll(ctx, newScroll);
3011
- checkFinishedScroll(ctx);
3022
+ if (state.scrollingTo) {
3023
+ checkFinishedScroll(ctx);
3024
+ }
3012
3025
  onScrollProp == null ? void 0 : onScrollProp(event);
3013
3026
  }
3014
3027
 
@@ -3343,6 +3356,24 @@ function getRenderedItem(ctx, key) {
3343
3356
  }
3344
3357
  return { index, item: data[index], renderedItem };
3345
3358
  }
3359
+
3360
+ // src/utils/normalizeMaintainVisibleContentPosition.ts
3361
+ function normalizeMaintainVisibleContentPosition(value) {
3362
+ var _a3, _b;
3363
+ if (value === true) {
3364
+ return { dataChanges: true, scroll: true };
3365
+ }
3366
+ if (value && typeof value === "object") {
3367
+ return {
3368
+ dataChanges: (_a3 = value.dataChanges) != null ? _a3 : false,
3369
+ scroll: (_b = value.scroll) != null ? _b : true
3370
+ };
3371
+ }
3372
+ if (value === false) {
3373
+ return { dataChanges: false, scroll: false };
3374
+ }
3375
+ return { dataChanges: false, scroll: true };
3376
+ }
3346
3377
  function useThrottleDebounce(mode) {
3347
3378
  const timeoutRef = useRef(null);
3348
3379
  const lastCallTimeRef = useRef(0);
@@ -3437,7 +3468,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3437
3468
  ListHeaderComponent,
3438
3469
  maintainScrollAtEnd = false,
3439
3470
  maintainScrollAtEndThreshold = 0.1,
3440
- maintainVisibleContentPosition = false,
3471
+ maintainVisibleContentPosition: maintainVisibleContentPositionProp,
3441
3472
  numColumns: numColumnsProp = 1,
3442
3473
  onEndReached,
3443
3474
  onEndReachedThreshold = 0.5,
@@ -3475,6 +3506,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3475
3506
  const style = { ...StyleSheet.flatten(styleProp) };
3476
3507
  const stylePaddingTopState = extractPadding(style, contentContainerStyle, "Top");
3477
3508
  const stylePaddingBottomState = extractPadding(style, contentContainerStyle, "Bottom");
3509
+ const maintainVisibleContentPositionConfig = normalizeMaintainVisibleContentPosition(
3510
+ maintainVisibleContentPositionProp
3511
+ );
3478
3512
  const [renderNum, setRenderNum] = useState(0);
3479
3513
  const initialScrollProp = initialScrollAtEnd ? { index: Math.max(0, dataProp.length - 1), viewOffset: -stylePaddingBottomState } : initialScrollIndexProp || initialScrollOffsetProp ? typeof initialScrollIndexProp === "object" ? { index: initialScrollIndexProp.index || 0, viewOffset: initialScrollIndexProp.viewOffset || 0 } : { index: initialScrollIndexProp || 0, viewOffset: initialScrollOffsetProp || 0 } : void 0;
3480
3514
  const [canRender, setCanRender] = React3.useState(!IsNewArchitecture);
@@ -3559,7 +3593,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3559
3593
  };
3560
3594
  const internalState = ctx.state;
3561
3595
  internalState.triggerCalculateItemsInView = (params) => calculateItemsInView(ctx, params);
3562
- set$(ctx, "maintainVisibleContentPosition", maintainVisibleContentPosition);
3596
+ set$(ctx, "maintainVisibleContentPosition", maintainVisibleContentPositionConfig);
3563
3597
  set$(ctx, "extraData", extraData);
3564
3598
  }
3565
3599
  refState.current = ctx.state;
@@ -3590,7 +3624,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3590
3624
  keyExtractor,
3591
3625
  maintainScrollAtEnd,
3592
3626
  maintainScrollAtEndThreshold,
3593
- maintainVisibleContentPosition,
3627
+ maintainVisibleContentPosition: maintainVisibleContentPositionConfig,
3594
3628
  numColumns: numColumnsProp,
3595
3629
  onEndReached,
3596
3630
  onEndReachedThreshold,
@@ -3625,7 +3659,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3625
3659
  setPaddingTop(ctx, { stylePaddingTop: stylePaddingTopState });
3626
3660
  refState.current.props.stylePaddingBottom = stylePaddingBottomState;
3627
3661
  let paddingDiff = stylePaddingTopState - prevPaddingTop;
3628
- if (paddingDiff && prevPaddingTop !== void 0 && Platform.OS === "ios") {
3662
+ if (maintainVisibleContentPositionConfig.scroll && paddingDiff && prevPaddingTop !== void 0 && Platform.OS === "ios") {
3629
3663
  if (state.scroll < 0) {
3630
3664
  paddingDiff += state.scroll;
3631
3665
  }
@@ -3660,7 +3694,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3660
3694
  value = 0;
3661
3695
  }
3662
3696
  if (!value) {
3663
- state.didFinishInitialScroll = true;
3697
+ setInitialRenderState(ctx, { didInitialScroll: true });
3664
3698
  }
3665
3699
  return value;
3666
3700
  }, [renderNum]);
@@ -3782,7 +3816,6 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3782
3816
  initialContentOffset,
3783
3817
  ListEmptyComponent: dataProp.length === 0 ? ListEmptyComponent : void 0,
3784
3818
  ListHeaderComponent,
3785
- maintainVisibleContentPosition,
3786
3819
  onLayout,
3787
3820
  onLayoutHeader,
3788
3821
  onMomentumScrollEnd: fns.onMomentumScrollEnd,
@@ -1,7 +1,7 @@
1
1
  import * as react_native from 'react-native';
2
2
  import { SectionListData, SectionBase, SectionListRenderItemInfo, SectionListScrollParams } from 'react-native';
3
3
  import * as React from 'react';
4
- import { a as LegendListRef, L as LegendListProps } from './types-1Hgg1rTO.mjs';
4
+ import { a as LegendListRef, L as LegendListProps } from './types-C83aU7VI.mjs';
5
5
  import 'react-native-reanimated';
6
6
 
7
7
  type SectionListSeparatorProps<ItemT, SectionT> = {
@@ -1,7 +1,7 @@
1
1
  import * as react_native from 'react-native';
2
2
  import { SectionListData, SectionBase, SectionListRenderItemInfo, SectionListScrollParams } from 'react-native';
3
3
  import * as React from 'react';
4
- import { a as LegendListRef, L as LegendListProps } from './types-1Hgg1rTO.js';
4
+ import { a as LegendListRef, L as LegendListProps } from './types-C83aU7VI.js';
5
5
  import 'react-native-reanimated';
6
6
 
7
7
  type SectionListSeparatorProps<ItemT, SectionT> = {