@legendapp/list 3.0.0-beta.11 → 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/index.native.js CHANGED
@@ -912,7 +912,6 @@ var ListComponent = typedMemo(function ListComponent2({
912
912
  getRenderedItem: getRenderedItem2,
913
913
  updateItemSize: updateItemSize2,
914
914
  refScrollView,
915
- maintainVisibleContentPosition,
916
915
  renderScrollComponent,
917
916
  scrollAdjustHandler,
918
917
  onLayoutHeader,
@@ -921,6 +920,7 @@ var ListComponent = typedMemo(function ListComponent2({
921
920
  ...rest
922
921
  }) {
923
922
  const ctx = useStateContext();
923
+ const maintainVisibleContentPosition = ctx.state.props.maintainVisibleContentPosition;
924
924
  const ScrollComponent = renderScrollComponent ? React2.useMemo(
925
925
  () => React2__namespace.forwardRef((props, ref) => renderScrollComponent({ ...props, ref })),
926
926
  [renderScrollComponent]
@@ -938,7 +938,7 @@ var ListComponent = typedMemo(function ListComponent2({
938
938
  ],
939
939
  contentOffset: initialContentOffset ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
940
940
  horizontal,
941
- maintainVisibleContentPosition: maintainVisibleContentPosition ? { minIndexForVisible: 0 } : void 0,
941
+ maintainVisibleContentPosition: maintainVisibleContentPosition.scroll || maintainVisibleContentPosition.dataChanges ? { minIndexForVisible: 0 } : void 0,
942
942
  onLayout,
943
943
  onScroll: onScroll2,
944
944
  ref: refScrollView,
@@ -1209,7 +1209,7 @@ function checkFinishedScrollFrame(ctx) {
1209
1209
  if (scrollingTo) {
1210
1210
  const { state } = ctx;
1211
1211
  state.animFrameCheckFinishedScroll = void 0;
1212
- const scroll = state.scroll;
1212
+ const scroll = state.scrollPending;
1213
1213
  const adjust = state.scrollAdjustHandler.getAdjust();
1214
1214
  const clampedTargetOffset = clampScrollOffset(ctx, scrollingTo.offset - (scrollingTo.viewOffset || 0));
1215
1215
  const maxOffset = clampScrollOffset(ctx, scroll);
@@ -1564,14 +1564,16 @@ function ensureInitialAnchor(ctx) {
1564
1564
  function prepareMVCP(ctx, dataChanged) {
1565
1565
  const state = ctx.state;
1566
1566
  const { idsInView, positions, props } = state;
1567
- const { maintainVisibleContentPosition } = props;
1567
+ const {
1568
+ maintainVisibleContentPosition: { dataChanges: mvcpDataChanges, scroll: mvcpScroll }
1569
+ } = props;
1568
1570
  const scrollingTo = state.scrollingTo;
1569
1571
  let prevPosition;
1570
1572
  let targetId;
1571
1573
  const idsInViewWithPositions = [];
1572
1574
  const scrollTarget = scrollingTo == null ? void 0 : scrollingTo.index;
1573
1575
  const scrollingToViewPosition = scrollingTo == null ? void 0 : scrollingTo.viewPosition;
1574
- const shouldMVCP = !dataChanged || maintainVisibleContentPosition;
1576
+ const shouldMVCP = dataChanged ? mvcpDataChanges : mvcpScroll;
1575
1577
  const indexByKey = state.indexByKey;
1576
1578
  if (shouldMVCP) {
1577
1579
  if (scrollTarget !== void 0) {
@@ -1597,7 +1599,7 @@ function prepareMVCP(ctx, dataChanged) {
1597
1599
  }
1598
1600
  return () => {
1599
1601
  let positionDiff = 0;
1600
- if (dataChanged && targetId === void 0 && maintainVisibleContentPosition) {
1602
+ if (dataChanged && targetId === void 0 && mvcpDataChanges) {
1601
1603
  for (let i = 0; i < idsInViewWithPositions.length; i++) {
1602
1604
  const { id, position } = idsInViewWithPositions[i];
1603
1605
  const newPosition = positions.get(id);
@@ -1634,7 +1636,7 @@ function prepareMVCP(ctx, dataChanged) {
1634
1636
  }
1635
1637
  }
1636
1638
  if (Math.abs(positionDiff) > 0.1) {
1637
- requestAdjust(ctx, positionDiff, dataChanged && maintainVisibleContentPosition);
1639
+ requestAdjust(ctx, positionDiff, dataChanged && mvcpDataChanges);
1638
1640
  }
1639
1641
  };
1640
1642
  }
@@ -1731,39 +1733,40 @@ function updateTotalSize(ctx) {
1731
1733
  // src/utils/getScrollVelocity.ts
1732
1734
  var getScrollVelocity = (state) => {
1733
1735
  const { scrollHistory } = state;
1734
- let velocity = 0;
1735
- if (scrollHistory.length >= 1) {
1736
- const newest = scrollHistory[scrollHistory.length - 1];
1737
- let oldest;
1738
- let start = 0;
1739
- const now = Date.now();
1740
- for (let i = 0; i < scrollHistory.length - 1; i++) {
1741
- const entry = scrollHistory[i];
1742
- const nextEntry = scrollHistory[i + 1];
1743
- if (i > 0) {
1744
- const prevEntry = scrollHistory[i - 1];
1745
- const prevDirection = entry.scroll - prevEntry.scroll;
1746
- const currentDirection = nextEntry.scroll - entry.scroll;
1747
- if (prevDirection > 0 && currentDirection < 0 || prevDirection < 0 && currentDirection > 0) {
1748
- start = i;
1749
- break;
1750
- }
1751
- }
1736
+ const newestIndex = scrollHistory.length - 1;
1737
+ if (newestIndex < 1) {
1738
+ return 0;
1739
+ }
1740
+ const newest = scrollHistory[newestIndex];
1741
+ const now = Date.now();
1742
+ let direction = 0;
1743
+ for (let i = newestIndex; i > 0; i--) {
1744
+ const delta = scrollHistory[i].scroll - scrollHistory[i - 1].scroll;
1745
+ if (delta !== 0) {
1746
+ direction = Math.sign(delta);
1747
+ break;
1752
1748
  }
1753
- for (let i = start; i < scrollHistory.length - 1; i++) {
1754
- const entry = scrollHistory[i];
1755
- if (now - entry.time <= 1e3) {
1756
- oldest = entry;
1757
- break;
1758
- }
1749
+ }
1750
+ if (direction === 0) {
1751
+ return 0;
1752
+ }
1753
+ let oldest = newest;
1754
+ for (let i = newestIndex - 1; i >= 0; i--) {
1755
+ const current = scrollHistory[i];
1756
+ const next = scrollHistory[i + 1];
1757
+ const delta = next.scroll - current.scroll;
1758
+ const deltaSign = Math.sign(delta);
1759
+ if (deltaSign !== 0 && deltaSign !== direction) {
1760
+ break;
1759
1761
  }
1760
- if (oldest && oldest !== newest) {
1761
- const scrollDiff = newest.scroll - oldest.scroll;
1762
- const timeDiff = newest.time - oldest.time;
1763
- velocity = timeDiff > 0 ? scrollDiff / timeDiff : 0;
1762
+ if (now - current.time > 1e3) {
1763
+ break;
1764
1764
  }
1765
+ oldest = current;
1765
1766
  }
1766
- return velocity;
1767
+ const scrollDiff = newest.scroll - oldest.scroll;
1768
+ const timeDiff = newest.time - oldest.time;
1769
+ return timeDiff > 0 ? scrollDiff / timeDiff : 0;
1767
1770
  };
1768
1771
 
1769
1772
  // src/utils/updateSnapToOffsets.ts
@@ -2922,7 +2925,6 @@ function onScroll(ctx, event) {
2922
2925
  return;
2923
2926
  }
2924
2927
  let newScroll = event.nativeEvent.contentOffset[state.props.horizontal ? "x" : "y"];
2925
- state.scrollPending = newScroll;
2926
2928
  if (state.scrollingTo) {
2927
2929
  const maxOffset = clampScrollOffset(ctx, newScroll);
2928
2930
  if (newScroll !== maxOffset && Math.abs(newScroll - maxOffset) > 1) {
@@ -2936,8 +2938,11 @@ function onScroll(ctx, event) {
2936
2938
  return;
2937
2939
  }
2938
2940
  }
2941
+ state.scrollPending = newScroll;
2939
2942
  updateScroll(ctx, newScroll);
2940
- checkFinishedScroll(ctx);
2943
+ if (state.scrollingTo) {
2944
+ checkFinishedScroll(ctx);
2945
+ }
2941
2946
  onScrollProp == null ? void 0 : onScrollProp(event);
2942
2947
  }
2943
2948
 
@@ -3291,6 +3296,24 @@ function getRenderedItem(ctx, key) {
3291
3296
  }
3292
3297
  return { index, item: data[index], renderedItem };
3293
3298
  }
3299
+
3300
+ // src/utils/normalizeMaintainVisibleContentPosition.ts
3301
+ function normalizeMaintainVisibleContentPosition(value) {
3302
+ var _a3, _b;
3303
+ if (value === true) {
3304
+ return { dataChanges: true, scroll: true };
3305
+ }
3306
+ if (value && typeof value === "object") {
3307
+ return {
3308
+ dataChanges: (_a3 = value.dataChanges) != null ? _a3 : false,
3309
+ scroll: (_b = value.scroll) != null ? _b : true
3310
+ };
3311
+ }
3312
+ if (value === false) {
3313
+ return { dataChanges: false, scroll: false };
3314
+ }
3315
+ return { dataChanges: false, scroll: true };
3316
+ }
3294
3317
  function useThrottleDebounce(mode) {
3295
3318
  const timeoutRef = React2.useRef(null);
3296
3319
  const lastCallTimeRef = React2.useRef(0);
@@ -3385,7 +3408,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3385
3408
  ListHeaderComponent,
3386
3409
  maintainScrollAtEnd = false,
3387
3410
  maintainScrollAtEndThreshold = 0.1,
3388
- maintainVisibleContentPosition = false,
3411
+ maintainVisibleContentPosition: maintainVisibleContentPositionProp,
3389
3412
  numColumns: numColumnsProp = 1,
3390
3413
  onEndReached,
3391
3414
  onEndReachedThreshold = 0.5,
@@ -3423,6 +3446,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3423
3446
  const style = { ...StyleSheet.flatten(styleProp) };
3424
3447
  const stylePaddingTopState = extractPadding(style, contentContainerStyle, "Top");
3425
3448
  const stylePaddingBottomState = extractPadding(style, contentContainerStyle, "Bottom");
3449
+ const maintainVisibleContentPositionConfig = normalizeMaintainVisibleContentPosition(
3450
+ maintainVisibleContentPositionProp
3451
+ );
3426
3452
  const [renderNum, setRenderNum] = React2.useState(0);
3427
3453
  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;
3428
3454
  const [canRender, setCanRender] = React2__namespace.useState(!IsNewArchitecture);
@@ -3507,7 +3533,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3507
3533
  };
3508
3534
  const internalState = ctx.state;
3509
3535
  internalState.triggerCalculateItemsInView = (params) => calculateItemsInView(ctx, params);
3510
- set$(ctx, "maintainVisibleContentPosition", maintainVisibleContentPosition);
3536
+ set$(ctx, "maintainVisibleContentPosition", maintainVisibleContentPositionConfig);
3511
3537
  set$(ctx, "extraData", extraData);
3512
3538
  }
3513
3539
  refState.current = ctx.state;
@@ -3538,7 +3564,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3538
3564
  keyExtractor,
3539
3565
  maintainScrollAtEnd,
3540
3566
  maintainScrollAtEndThreshold,
3541
- maintainVisibleContentPosition,
3567
+ maintainVisibleContentPosition: maintainVisibleContentPositionConfig,
3542
3568
  numColumns: numColumnsProp,
3543
3569
  onEndReached,
3544
3570
  onEndReachedThreshold,
@@ -3573,7 +3599,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3573
3599
  setPaddingTop(ctx, { stylePaddingTop: stylePaddingTopState });
3574
3600
  refState.current.props.stylePaddingBottom = stylePaddingBottomState;
3575
3601
  let paddingDiff = stylePaddingTopState - prevPaddingTop;
3576
- if (paddingDiff && prevPaddingTop !== void 0 && Platform2.OS === "ios") {
3602
+ if (maintainVisibleContentPositionConfig.scroll && paddingDiff && prevPaddingTop !== void 0 && Platform2.OS === "ios") {
3577
3603
  if (state.scroll < 0) {
3578
3604
  paddingDiff += state.scroll;
3579
3605
  }
@@ -3618,7 +3644,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3618
3644
  value = 0;
3619
3645
  }
3620
3646
  if (!value) {
3621
- state.didFinishInitialScroll = true;
3647
+ setInitialRenderState(ctx, { didInitialScroll: true });
3622
3648
  }
3623
3649
  return value;
3624
3650
  }, [renderNum]);
@@ -3747,7 +3773,6 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3747
3773
  initialContentOffset,
3748
3774
  ListEmptyComponent: dataProp.length === 0 ? ListEmptyComponent : void 0,
3749
3775
  ListHeaderComponent,
3750
- maintainVisibleContentPosition,
3751
3776
  onLayout,
3752
3777
  onLayoutHeader,
3753
3778
  onMomentumScrollEnd: fns.onMomentumScrollEnd,
package/index.native.mjs CHANGED
@@ -891,7 +891,6 @@ var ListComponent = typedMemo(function ListComponent2({
891
891
  getRenderedItem: getRenderedItem2,
892
892
  updateItemSize: updateItemSize2,
893
893
  refScrollView,
894
- maintainVisibleContentPosition,
895
894
  renderScrollComponent,
896
895
  scrollAdjustHandler,
897
896
  onLayoutHeader,
@@ -900,6 +899,7 @@ var ListComponent = typedMemo(function ListComponent2({
900
899
  ...rest
901
900
  }) {
902
901
  const ctx = useStateContext();
902
+ const maintainVisibleContentPosition = ctx.state.props.maintainVisibleContentPosition;
903
903
  const ScrollComponent = renderScrollComponent ? useMemo(
904
904
  () => React2.forwardRef((props, ref) => renderScrollComponent({ ...props, ref })),
905
905
  [renderScrollComponent]
@@ -917,7 +917,7 @@ var ListComponent = typedMemo(function ListComponent2({
917
917
  ],
918
918
  contentOffset: initialContentOffset ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
919
919
  horizontal,
920
- maintainVisibleContentPosition: maintainVisibleContentPosition ? { minIndexForVisible: 0 } : void 0,
920
+ maintainVisibleContentPosition: maintainVisibleContentPosition.scroll || maintainVisibleContentPosition.dataChanges ? { minIndexForVisible: 0 } : void 0,
921
921
  onLayout,
922
922
  onScroll: onScroll2,
923
923
  ref: refScrollView,
@@ -1188,7 +1188,7 @@ function checkFinishedScrollFrame(ctx) {
1188
1188
  if (scrollingTo) {
1189
1189
  const { state } = ctx;
1190
1190
  state.animFrameCheckFinishedScroll = void 0;
1191
- const scroll = state.scroll;
1191
+ const scroll = state.scrollPending;
1192
1192
  const adjust = state.scrollAdjustHandler.getAdjust();
1193
1193
  const clampedTargetOffset = clampScrollOffset(ctx, scrollingTo.offset - (scrollingTo.viewOffset || 0));
1194
1194
  const maxOffset = clampScrollOffset(ctx, scroll);
@@ -1543,14 +1543,16 @@ function ensureInitialAnchor(ctx) {
1543
1543
  function prepareMVCP(ctx, dataChanged) {
1544
1544
  const state = ctx.state;
1545
1545
  const { idsInView, positions, props } = state;
1546
- const { maintainVisibleContentPosition } = props;
1546
+ const {
1547
+ maintainVisibleContentPosition: { dataChanges: mvcpDataChanges, scroll: mvcpScroll }
1548
+ } = props;
1547
1549
  const scrollingTo = state.scrollingTo;
1548
1550
  let prevPosition;
1549
1551
  let targetId;
1550
1552
  const idsInViewWithPositions = [];
1551
1553
  const scrollTarget = scrollingTo == null ? void 0 : scrollingTo.index;
1552
1554
  const scrollingToViewPosition = scrollingTo == null ? void 0 : scrollingTo.viewPosition;
1553
- const shouldMVCP = !dataChanged || maintainVisibleContentPosition;
1555
+ const shouldMVCP = dataChanged ? mvcpDataChanges : mvcpScroll;
1554
1556
  const indexByKey = state.indexByKey;
1555
1557
  if (shouldMVCP) {
1556
1558
  if (scrollTarget !== void 0) {
@@ -1576,7 +1578,7 @@ function prepareMVCP(ctx, dataChanged) {
1576
1578
  }
1577
1579
  return () => {
1578
1580
  let positionDiff = 0;
1579
- if (dataChanged && targetId === void 0 && maintainVisibleContentPosition) {
1581
+ if (dataChanged && targetId === void 0 && mvcpDataChanges) {
1580
1582
  for (let i = 0; i < idsInViewWithPositions.length; i++) {
1581
1583
  const { id, position } = idsInViewWithPositions[i];
1582
1584
  const newPosition = positions.get(id);
@@ -1613,7 +1615,7 @@ function prepareMVCP(ctx, dataChanged) {
1613
1615
  }
1614
1616
  }
1615
1617
  if (Math.abs(positionDiff) > 0.1) {
1616
- requestAdjust(ctx, positionDiff, dataChanged && maintainVisibleContentPosition);
1618
+ requestAdjust(ctx, positionDiff, dataChanged && mvcpDataChanges);
1617
1619
  }
1618
1620
  };
1619
1621
  }
@@ -1710,39 +1712,40 @@ function updateTotalSize(ctx) {
1710
1712
  // src/utils/getScrollVelocity.ts
1711
1713
  var getScrollVelocity = (state) => {
1712
1714
  const { scrollHistory } = state;
1713
- let velocity = 0;
1714
- if (scrollHistory.length >= 1) {
1715
- const newest = scrollHistory[scrollHistory.length - 1];
1716
- let oldest;
1717
- let start = 0;
1718
- const now = Date.now();
1719
- for (let i = 0; i < scrollHistory.length - 1; i++) {
1720
- const entry = scrollHistory[i];
1721
- const nextEntry = scrollHistory[i + 1];
1722
- if (i > 0) {
1723
- const prevEntry = scrollHistory[i - 1];
1724
- const prevDirection = entry.scroll - prevEntry.scroll;
1725
- const currentDirection = nextEntry.scroll - entry.scroll;
1726
- if (prevDirection > 0 && currentDirection < 0 || prevDirection < 0 && currentDirection > 0) {
1727
- start = i;
1728
- break;
1729
- }
1730
- }
1715
+ const newestIndex = scrollHistory.length - 1;
1716
+ if (newestIndex < 1) {
1717
+ return 0;
1718
+ }
1719
+ const newest = scrollHistory[newestIndex];
1720
+ const now = Date.now();
1721
+ let direction = 0;
1722
+ for (let i = newestIndex; i > 0; i--) {
1723
+ const delta = scrollHistory[i].scroll - scrollHistory[i - 1].scroll;
1724
+ if (delta !== 0) {
1725
+ direction = Math.sign(delta);
1726
+ break;
1731
1727
  }
1732
- for (let i = start; i < scrollHistory.length - 1; i++) {
1733
- const entry = scrollHistory[i];
1734
- if (now - entry.time <= 1e3) {
1735
- oldest = entry;
1736
- break;
1737
- }
1728
+ }
1729
+ if (direction === 0) {
1730
+ return 0;
1731
+ }
1732
+ let oldest = newest;
1733
+ for (let i = newestIndex - 1; i >= 0; i--) {
1734
+ const current = scrollHistory[i];
1735
+ const next = scrollHistory[i + 1];
1736
+ const delta = next.scroll - current.scroll;
1737
+ const deltaSign = Math.sign(delta);
1738
+ if (deltaSign !== 0 && deltaSign !== direction) {
1739
+ break;
1738
1740
  }
1739
- if (oldest && oldest !== newest) {
1740
- const scrollDiff = newest.scroll - oldest.scroll;
1741
- const timeDiff = newest.time - oldest.time;
1742
- velocity = timeDiff > 0 ? scrollDiff / timeDiff : 0;
1741
+ if (now - current.time > 1e3) {
1742
+ break;
1743
1743
  }
1744
+ oldest = current;
1744
1745
  }
1745
- return velocity;
1746
+ const scrollDiff = newest.scroll - oldest.scroll;
1747
+ const timeDiff = newest.time - oldest.time;
1748
+ return timeDiff > 0 ? scrollDiff / timeDiff : 0;
1746
1749
  };
1747
1750
 
1748
1751
  // src/utils/updateSnapToOffsets.ts
@@ -2901,7 +2904,6 @@ function onScroll(ctx, event) {
2901
2904
  return;
2902
2905
  }
2903
2906
  let newScroll = event.nativeEvent.contentOffset[state.props.horizontal ? "x" : "y"];
2904
- state.scrollPending = newScroll;
2905
2907
  if (state.scrollingTo) {
2906
2908
  const maxOffset = clampScrollOffset(ctx, newScroll);
2907
2909
  if (newScroll !== maxOffset && Math.abs(newScroll - maxOffset) > 1) {
@@ -2915,8 +2917,11 @@ function onScroll(ctx, event) {
2915
2917
  return;
2916
2918
  }
2917
2919
  }
2920
+ state.scrollPending = newScroll;
2918
2921
  updateScroll(ctx, newScroll);
2919
- checkFinishedScroll(ctx);
2922
+ if (state.scrollingTo) {
2923
+ checkFinishedScroll(ctx);
2924
+ }
2920
2925
  onScrollProp == null ? void 0 : onScrollProp(event);
2921
2926
  }
2922
2927
 
@@ -3270,6 +3275,24 @@ function getRenderedItem(ctx, key) {
3270
3275
  }
3271
3276
  return { index, item: data[index], renderedItem };
3272
3277
  }
3278
+
3279
+ // src/utils/normalizeMaintainVisibleContentPosition.ts
3280
+ function normalizeMaintainVisibleContentPosition(value) {
3281
+ var _a3, _b;
3282
+ if (value === true) {
3283
+ return { dataChanges: true, scroll: true };
3284
+ }
3285
+ if (value && typeof value === "object") {
3286
+ return {
3287
+ dataChanges: (_a3 = value.dataChanges) != null ? _a3 : false,
3288
+ scroll: (_b = value.scroll) != null ? _b : true
3289
+ };
3290
+ }
3291
+ if (value === false) {
3292
+ return { dataChanges: false, scroll: false };
3293
+ }
3294
+ return { dataChanges: false, scroll: true };
3295
+ }
3273
3296
  function useThrottleDebounce(mode) {
3274
3297
  const timeoutRef = useRef(null);
3275
3298
  const lastCallTimeRef = useRef(0);
@@ -3364,7 +3387,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3364
3387
  ListHeaderComponent,
3365
3388
  maintainScrollAtEnd = false,
3366
3389
  maintainScrollAtEndThreshold = 0.1,
3367
- maintainVisibleContentPosition = false,
3390
+ maintainVisibleContentPosition: maintainVisibleContentPositionProp,
3368
3391
  numColumns: numColumnsProp = 1,
3369
3392
  onEndReached,
3370
3393
  onEndReachedThreshold = 0.5,
@@ -3402,6 +3425,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3402
3425
  const style = { ...StyleSheet.flatten(styleProp) };
3403
3426
  const stylePaddingTopState = extractPadding(style, contentContainerStyle, "Top");
3404
3427
  const stylePaddingBottomState = extractPadding(style, contentContainerStyle, "Bottom");
3428
+ const maintainVisibleContentPositionConfig = normalizeMaintainVisibleContentPosition(
3429
+ maintainVisibleContentPositionProp
3430
+ );
3405
3431
  const [renderNum, setRenderNum] = useState(0);
3406
3432
  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;
3407
3433
  const [canRender, setCanRender] = React2.useState(!IsNewArchitecture);
@@ -3486,7 +3512,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3486
3512
  };
3487
3513
  const internalState = ctx.state;
3488
3514
  internalState.triggerCalculateItemsInView = (params) => calculateItemsInView(ctx, params);
3489
- set$(ctx, "maintainVisibleContentPosition", maintainVisibleContentPosition);
3515
+ set$(ctx, "maintainVisibleContentPosition", maintainVisibleContentPositionConfig);
3490
3516
  set$(ctx, "extraData", extraData);
3491
3517
  }
3492
3518
  refState.current = ctx.state;
@@ -3517,7 +3543,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3517
3543
  keyExtractor,
3518
3544
  maintainScrollAtEnd,
3519
3545
  maintainScrollAtEndThreshold,
3520
- maintainVisibleContentPosition,
3546
+ maintainVisibleContentPosition: maintainVisibleContentPositionConfig,
3521
3547
  numColumns: numColumnsProp,
3522
3548
  onEndReached,
3523
3549
  onEndReachedThreshold,
@@ -3552,7 +3578,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3552
3578
  setPaddingTop(ctx, { stylePaddingTop: stylePaddingTopState });
3553
3579
  refState.current.props.stylePaddingBottom = stylePaddingBottomState;
3554
3580
  let paddingDiff = stylePaddingTopState - prevPaddingTop;
3555
- if (paddingDiff && prevPaddingTop !== void 0 && Platform2.OS === "ios") {
3581
+ if (maintainVisibleContentPositionConfig.scroll && paddingDiff && prevPaddingTop !== void 0 && Platform2.OS === "ios") {
3556
3582
  if (state.scroll < 0) {
3557
3583
  paddingDiff += state.scroll;
3558
3584
  }
@@ -3597,7 +3623,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3597
3623
  value = 0;
3598
3624
  }
3599
3625
  if (!value) {
3600
- state.didFinishInitialScroll = true;
3626
+ setInitialRenderState(ctx, { didInitialScroll: true });
3601
3627
  }
3602
3628
  return value;
3603
3629
  }, [renderNum]);
@@ -3726,7 +3752,6 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3726
3752
  initialContentOffset,
3727
3753
  ListEmptyComponent: dataProp.length === 0 ? ListEmptyComponent : void 0,
3728
3754
  ListHeaderComponent,
3729
- maintainVisibleContentPosition,
3730
3755
  onLayout,
3731
3756
  onLayoutHeader,
3732
3757
  onMomentumScrollEnd: fns.onMomentumScrollEnd,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/list",
3
- "version": "3.0.0-beta.11",
3
+ "version": "3.0.0-beta.12",
4
4
  "description": "Legend List is a drop-in replacement for FlatList with much better performance and supporting dynamically sized items.",
5
5
  "sideEffects": false,
6
6
  "private": false,
@@ -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> = {
package/section-list.d.ts CHANGED
@@ -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> = {