@legendapp/list 3.0.0-beta.11 → 3.0.0-beta.13

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.
@@ -781,7 +781,6 @@ var ListComponent = typedMemo(function ListComponent2({
781
781
  getRenderedItem: getRenderedItem2,
782
782
  updateItemSize: updateItemSize2,
783
783
  refScrollView,
784
- maintainVisibleContentPosition,
785
784
  renderScrollComponent,
786
785
  scrollAdjustHandler,
787
786
  onLayoutHeader,
@@ -790,6 +789,7 @@ var ListComponent = typedMemo(function ListComponent2({
790
789
  ...rest
791
790
  }) {
792
791
  const ctx = useStateContext();
792
+ const maintainVisibleContentPosition = ctx.state.props.maintainVisibleContentPosition;
793
793
  const ScrollComponent = renderScrollComponent ? React2.useMemo(
794
794
  () => React2__namespace.forwardRef((props, ref) => renderScrollComponent({ ...props, ref })),
795
795
  [renderScrollComponent]
@@ -807,7 +807,7 @@ var ListComponent = typedMemo(function ListComponent2({
807
807
  ],
808
808
  contentOffset: initialContentOffset ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
809
809
  horizontal,
810
- maintainVisibleContentPosition: maintainVisibleContentPosition ? { minIndexForVisible: 0 } : void 0,
810
+ maintainVisibleContentPosition: maintainVisibleContentPosition.scroll || maintainVisibleContentPosition.dataChanged ? { minIndexForVisible: 0 } : void 0,
811
811
  onLayout,
812
812
  onScroll: onScroll2,
813
813
  ref: refScrollView,
@@ -1078,7 +1078,7 @@ function checkFinishedScrollFrame(ctx) {
1078
1078
  if (scrollingTo) {
1079
1079
  const { state } = ctx;
1080
1080
  state.animFrameCheckFinishedScroll = void 0;
1081
- const scroll = state.scroll;
1081
+ const scroll = state.scrollPending;
1082
1082
  const adjust = state.scrollAdjustHandler.getAdjust();
1083
1083
  const clampedTargetOffset = clampScrollOffset(ctx, scrollingTo.offset - (scrollingTo.viewOffset || 0));
1084
1084
  const maxOffset = clampScrollOffset(ctx, scroll);
@@ -1433,14 +1433,16 @@ function ensureInitialAnchor(ctx) {
1433
1433
  function prepareMVCP(ctx, dataChanged) {
1434
1434
  const state = ctx.state;
1435
1435
  const { idsInView, positions, props } = state;
1436
- const { maintainVisibleContentPosition } = props;
1436
+ const {
1437
+ maintainVisibleContentPosition: { dataChanged: mvcpdataChanged, scroll: mvcpScroll }
1438
+ } = props;
1437
1439
  const scrollingTo = state.scrollingTo;
1438
1440
  let prevPosition;
1439
1441
  let targetId;
1440
1442
  const idsInViewWithPositions = [];
1441
1443
  const scrollTarget = scrollingTo == null ? void 0 : scrollingTo.index;
1442
1444
  const scrollingToViewPosition = scrollingTo == null ? void 0 : scrollingTo.viewPosition;
1443
- const shouldMVCP = !dataChanged || maintainVisibleContentPosition;
1445
+ const shouldMVCP = dataChanged ? mvcpdataChanged : mvcpScroll;
1444
1446
  const indexByKey = state.indexByKey;
1445
1447
  if (shouldMVCP) {
1446
1448
  if (scrollTarget !== void 0) {
@@ -1466,7 +1468,7 @@ function prepareMVCP(ctx, dataChanged) {
1466
1468
  }
1467
1469
  return () => {
1468
1470
  let positionDiff = 0;
1469
- if (dataChanged && targetId === void 0 && maintainVisibleContentPosition) {
1471
+ if (dataChanged && targetId === void 0 && mvcpdataChanged) {
1470
1472
  for (let i = 0; i < idsInViewWithPositions.length; i++) {
1471
1473
  const { id, position } = idsInViewWithPositions[i];
1472
1474
  const newPosition = positions.get(id);
@@ -1503,7 +1505,7 @@ function prepareMVCP(ctx, dataChanged) {
1503
1505
  }
1504
1506
  }
1505
1507
  if (Math.abs(positionDiff) > 0.1) {
1506
- requestAdjust(ctx, positionDiff, dataChanged && maintainVisibleContentPosition);
1508
+ requestAdjust(ctx, positionDiff, dataChanged && mvcpdataChanged);
1507
1509
  }
1508
1510
  };
1509
1511
  }
@@ -1600,39 +1602,40 @@ function updateTotalSize(ctx) {
1600
1602
  // src/utils/getScrollVelocity.ts
1601
1603
  var getScrollVelocity = (state) => {
1602
1604
  const { scrollHistory } = state;
1603
- let velocity = 0;
1604
- if (scrollHistory.length >= 1) {
1605
- const newest = scrollHistory[scrollHistory.length - 1];
1606
- let oldest;
1607
- let start = 0;
1608
- const now = Date.now();
1609
- for (let i = 0; i < scrollHistory.length - 1; i++) {
1610
- const entry = scrollHistory[i];
1611
- const nextEntry = scrollHistory[i + 1];
1612
- if (i > 0) {
1613
- const prevEntry = scrollHistory[i - 1];
1614
- const prevDirection = entry.scroll - prevEntry.scroll;
1615
- const currentDirection = nextEntry.scroll - entry.scroll;
1616
- if (prevDirection > 0 && currentDirection < 0 || prevDirection < 0 && currentDirection > 0) {
1617
- start = i;
1618
- break;
1619
- }
1620
- }
1605
+ const newestIndex = scrollHistory.length - 1;
1606
+ if (newestIndex < 1) {
1607
+ return 0;
1608
+ }
1609
+ const newest = scrollHistory[newestIndex];
1610
+ const now = Date.now();
1611
+ let direction = 0;
1612
+ for (let i = newestIndex; i > 0; i--) {
1613
+ const delta = scrollHistory[i].scroll - scrollHistory[i - 1].scroll;
1614
+ if (delta !== 0) {
1615
+ direction = Math.sign(delta);
1616
+ break;
1621
1617
  }
1622
- for (let i = start; i < scrollHistory.length - 1; i++) {
1623
- const entry = scrollHistory[i];
1624
- if (now - entry.time <= 1e3) {
1625
- oldest = entry;
1626
- break;
1627
- }
1618
+ }
1619
+ if (direction === 0) {
1620
+ return 0;
1621
+ }
1622
+ let oldest = newest;
1623
+ for (let i = newestIndex - 1; i >= 0; i--) {
1624
+ const current = scrollHistory[i];
1625
+ const next = scrollHistory[i + 1];
1626
+ const delta = next.scroll - current.scroll;
1627
+ const deltaSign = Math.sign(delta);
1628
+ if (deltaSign !== 0 && deltaSign !== direction) {
1629
+ break;
1628
1630
  }
1629
- if (oldest && oldest !== newest) {
1630
- const scrollDiff = newest.scroll - oldest.scroll;
1631
- const timeDiff = newest.time - oldest.time;
1632
- velocity = timeDiff > 0 ? scrollDiff / timeDiff : 0;
1631
+ if (now - current.time > 1e3) {
1632
+ break;
1633
1633
  }
1634
+ oldest = current;
1634
1635
  }
1635
- return velocity;
1636
+ const scrollDiff = newest.scroll - oldest.scroll;
1637
+ const timeDiff = newest.time - oldest.time;
1638
+ return timeDiff > 0 ? scrollDiff / timeDiff : 0;
1636
1639
  };
1637
1640
 
1638
1641
  // src/utils/updateSnapToOffsets.ts
@@ -2791,7 +2794,6 @@ function onScroll(ctx, event) {
2791
2794
  return;
2792
2795
  }
2793
2796
  let newScroll = event.nativeEvent.contentOffset[state.props.horizontal ? "x" : "y"];
2794
- state.scrollPending = newScroll;
2795
2797
  if (state.scrollingTo) {
2796
2798
  const maxOffset = clampScrollOffset(ctx, newScroll);
2797
2799
  if (newScroll !== maxOffset && Math.abs(newScroll - maxOffset) > 1) {
@@ -2805,8 +2807,11 @@ function onScroll(ctx, event) {
2805
2807
  return;
2806
2808
  }
2807
2809
  }
2810
+ state.scrollPending = newScroll;
2808
2811
  updateScroll(ctx, newScroll);
2809
- checkFinishedScroll(ctx);
2812
+ if (state.scrollingTo) {
2813
+ checkFinishedScroll(ctx);
2814
+ }
2810
2815
  onScrollProp == null ? void 0 : onScrollProp(event);
2811
2816
  }
2812
2817
 
@@ -3160,6 +3165,24 @@ function getRenderedItem(ctx, key) {
3160
3165
  }
3161
3166
  return { index, item: data[index], renderedItem };
3162
3167
  }
3168
+
3169
+ // src/utils/normalizeMaintainVisibleContentPosition.ts
3170
+ function normalizeMaintainVisibleContentPosition(value) {
3171
+ var _a3, _b;
3172
+ if (value === true) {
3173
+ return { dataChanged: true, scroll: true };
3174
+ }
3175
+ if (value && typeof value === "object") {
3176
+ return {
3177
+ dataChanged: (_a3 = value.dataChanged) != null ? _a3 : false,
3178
+ scroll: (_b = value.scroll) != null ? _b : true
3179
+ };
3180
+ }
3181
+ if (value === false) {
3182
+ return { dataChanged: false, scroll: false };
3183
+ }
3184
+ return { dataChanged: false, scroll: true };
3185
+ }
3163
3186
  function useThrottleDebounce(mode) {
3164
3187
  const timeoutRef = React2.useRef(null);
3165
3188
  const lastCallTimeRef = React2.useRef(0);
@@ -3254,7 +3277,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3254
3277
  ListHeaderComponent,
3255
3278
  maintainScrollAtEnd = false,
3256
3279
  maintainScrollAtEndThreshold = 0.1,
3257
- maintainVisibleContentPosition = false,
3280
+ maintainVisibleContentPosition: maintainVisibleContentPositionProp,
3258
3281
  numColumns: numColumnsProp = 1,
3259
3282
  onEndReached,
3260
3283
  onEndReachedThreshold = 0.5,
@@ -3292,6 +3315,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3292
3315
  const style = { ...StyleSheet.flatten(styleProp) };
3293
3316
  const stylePaddingTopState = extractPadding(style, contentContainerStyle, "Top");
3294
3317
  const stylePaddingBottomState = extractPadding(style, contentContainerStyle, "Bottom");
3318
+ const maintainVisibleContentPositionConfig = normalizeMaintainVisibleContentPosition(
3319
+ maintainVisibleContentPositionProp
3320
+ );
3295
3321
  const [renderNum, setRenderNum] = React2.useState(0);
3296
3322
  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;
3297
3323
  const [canRender, setCanRender] = React2__namespace.useState(!IsNewArchitecture);
@@ -3376,7 +3402,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3376
3402
  };
3377
3403
  const internalState = ctx.state;
3378
3404
  internalState.triggerCalculateItemsInView = (params) => calculateItemsInView(ctx, params);
3379
- set$(ctx, "maintainVisibleContentPosition", maintainVisibleContentPosition);
3405
+ set$(ctx, "maintainVisibleContentPosition", maintainVisibleContentPositionConfig);
3380
3406
  set$(ctx, "extraData", extraData);
3381
3407
  }
3382
3408
  refState.current = ctx.state;
@@ -3407,7 +3433,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3407
3433
  keyExtractor,
3408
3434
  maintainScrollAtEnd,
3409
3435
  maintainScrollAtEndThreshold,
3410
- maintainVisibleContentPosition,
3436
+ maintainVisibleContentPosition: maintainVisibleContentPositionConfig,
3411
3437
  numColumns: numColumnsProp,
3412
3438
  onEndReached,
3413
3439
  onEndReachedThreshold,
@@ -3442,7 +3468,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3442
3468
  setPaddingTop(ctx, { stylePaddingTop: stylePaddingTopState });
3443
3469
  refState.current.props.stylePaddingBottom = stylePaddingBottomState;
3444
3470
  let paddingDiff = stylePaddingTopState - prevPaddingTop;
3445
- if (paddingDiff && prevPaddingTop !== void 0 && Platform2.OS === "ios") {
3471
+ if (maintainVisibleContentPositionConfig.scroll && paddingDiff && prevPaddingTop !== void 0 && Platform2.OS === "ios") {
3446
3472
  if (state.scroll < 0) {
3447
3473
  paddingDiff += state.scroll;
3448
3474
  }
@@ -3487,7 +3513,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3487
3513
  value = 0;
3488
3514
  }
3489
3515
  if (!value) {
3490
- state.didFinishInitialScroll = true;
3516
+ setInitialRenderState(ctx, { didInitialScroll: true });
3491
3517
  }
3492
3518
  return value;
3493
3519
  }, [renderNum]);
@@ -3616,7 +3642,6 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3616
3642
  initialContentOffset,
3617
3643
  ListEmptyComponent: dataProp.length === 0 ? ListEmptyComponent : void 0,
3618
3644
  ListHeaderComponent,
3619
- maintainVisibleContentPosition,
3620
3645
  onLayout,
3621
3646
  onLayoutHeader,
3622
3647
  onMomentumScrollEnd: fns.onMomentumScrollEnd,
@@ -760,7 +760,6 @@ var ListComponent = typedMemo(function ListComponent2({
760
760
  getRenderedItem: getRenderedItem2,
761
761
  updateItemSize: updateItemSize2,
762
762
  refScrollView,
763
- maintainVisibleContentPosition,
764
763
  renderScrollComponent,
765
764
  scrollAdjustHandler,
766
765
  onLayoutHeader,
@@ -769,6 +768,7 @@ var ListComponent = typedMemo(function ListComponent2({
769
768
  ...rest
770
769
  }) {
771
770
  const ctx = useStateContext();
771
+ const maintainVisibleContentPosition = ctx.state.props.maintainVisibleContentPosition;
772
772
  const ScrollComponent = renderScrollComponent ? useMemo(
773
773
  () => React2.forwardRef((props, ref) => renderScrollComponent({ ...props, ref })),
774
774
  [renderScrollComponent]
@@ -786,7 +786,7 @@ var ListComponent = typedMemo(function ListComponent2({
786
786
  ],
787
787
  contentOffset: initialContentOffset ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
788
788
  horizontal,
789
- maintainVisibleContentPosition: maintainVisibleContentPosition ? { minIndexForVisible: 0 } : void 0,
789
+ maintainVisibleContentPosition: maintainVisibleContentPosition.scroll || maintainVisibleContentPosition.dataChanged ? { minIndexForVisible: 0 } : void 0,
790
790
  onLayout,
791
791
  onScroll: onScroll2,
792
792
  ref: refScrollView,
@@ -1057,7 +1057,7 @@ function checkFinishedScrollFrame(ctx) {
1057
1057
  if (scrollingTo) {
1058
1058
  const { state } = ctx;
1059
1059
  state.animFrameCheckFinishedScroll = void 0;
1060
- const scroll = state.scroll;
1060
+ const scroll = state.scrollPending;
1061
1061
  const adjust = state.scrollAdjustHandler.getAdjust();
1062
1062
  const clampedTargetOffset = clampScrollOffset(ctx, scrollingTo.offset - (scrollingTo.viewOffset || 0));
1063
1063
  const maxOffset = clampScrollOffset(ctx, scroll);
@@ -1412,14 +1412,16 @@ function ensureInitialAnchor(ctx) {
1412
1412
  function prepareMVCP(ctx, dataChanged) {
1413
1413
  const state = ctx.state;
1414
1414
  const { idsInView, positions, props } = state;
1415
- const { maintainVisibleContentPosition } = props;
1415
+ const {
1416
+ maintainVisibleContentPosition: { dataChanged: mvcpdataChanged, scroll: mvcpScroll }
1417
+ } = props;
1416
1418
  const scrollingTo = state.scrollingTo;
1417
1419
  let prevPosition;
1418
1420
  let targetId;
1419
1421
  const idsInViewWithPositions = [];
1420
1422
  const scrollTarget = scrollingTo == null ? void 0 : scrollingTo.index;
1421
1423
  const scrollingToViewPosition = scrollingTo == null ? void 0 : scrollingTo.viewPosition;
1422
- const shouldMVCP = !dataChanged || maintainVisibleContentPosition;
1424
+ const shouldMVCP = dataChanged ? mvcpdataChanged : mvcpScroll;
1423
1425
  const indexByKey = state.indexByKey;
1424
1426
  if (shouldMVCP) {
1425
1427
  if (scrollTarget !== void 0) {
@@ -1445,7 +1447,7 @@ function prepareMVCP(ctx, dataChanged) {
1445
1447
  }
1446
1448
  return () => {
1447
1449
  let positionDiff = 0;
1448
- if (dataChanged && targetId === void 0 && maintainVisibleContentPosition) {
1450
+ if (dataChanged && targetId === void 0 && mvcpdataChanged) {
1449
1451
  for (let i = 0; i < idsInViewWithPositions.length; i++) {
1450
1452
  const { id, position } = idsInViewWithPositions[i];
1451
1453
  const newPosition = positions.get(id);
@@ -1482,7 +1484,7 @@ function prepareMVCP(ctx, dataChanged) {
1482
1484
  }
1483
1485
  }
1484
1486
  if (Math.abs(positionDiff) > 0.1) {
1485
- requestAdjust(ctx, positionDiff, dataChanged && maintainVisibleContentPosition);
1487
+ requestAdjust(ctx, positionDiff, dataChanged && mvcpdataChanged);
1486
1488
  }
1487
1489
  };
1488
1490
  }
@@ -1579,39 +1581,40 @@ function updateTotalSize(ctx) {
1579
1581
  // src/utils/getScrollVelocity.ts
1580
1582
  var getScrollVelocity = (state) => {
1581
1583
  const { scrollHistory } = state;
1582
- let velocity = 0;
1583
- if (scrollHistory.length >= 1) {
1584
- const newest = scrollHistory[scrollHistory.length - 1];
1585
- let oldest;
1586
- let start = 0;
1587
- const now = Date.now();
1588
- for (let i = 0; i < scrollHistory.length - 1; i++) {
1589
- const entry = scrollHistory[i];
1590
- const nextEntry = scrollHistory[i + 1];
1591
- if (i > 0) {
1592
- const prevEntry = scrollHistory[i - 1];
1593
- const prevDirection = entry.scroll - prevEntry.scroll;
1594
- const currentDirection = nextEntry.scroll - entry.scroll;
1595
- if (prevDirection > 0 && currentDirection < 0 || prevDirection < 0 && currentDirection > 0) {
1596
- start = i;
1597
- break;
1598
- }
1599
- }
1584
+ const newestIndex = scrollHistory.length - 1;
1585
+ if (newestIndex < 1) {
1586
+ return 0;
1587
+ }
1588
+ const newest = scrollHistory[newestIndex];
1589
+ const now = Date.now();
1590
+ let direction = 0;
1591
+ for (let i = newestIndex; i > 0; i--) {
1592
+ const delta = scrollHistory[i].scroll - scrollHistory[i - 1].scroll;
1593
+ if (delta !== 0) {
1594
+ direction = Math.sign(delta);
1595
+ break;
1600
1596
  }
1601
- for (let i = start; i < scrollHistory.length - 1; i++) {
1602
- const entry = scrollHistory[i];
1603
- if (now - entry.time <= 1e3) {
1604
- oldest = entry;
1605
- break;
1606
- }
1597
+ }
1598
+ if (direction === 0) {
1599
+ return 0;
1600
+ }
1601
+ let oldest = newest;
1602
+ for (let i = newestIndex - 1; i >= 0; i--) {
1603
+ const current = scrollHistory[i];
1604
+ const next = scrollHistory[i + 1];
1605
+ const delta = next.scroll - current.scroll;
1606
+ const deltaSign = Math.sign(delta);
1607
+ if (deltaSign !== 0 && deltaSign !== direction) {
1608
+ break;
1607
1609
  }
1608
- if (oldest && oldest !== newest) {
1609
- const scrollDiff = newest.scroll - oldest.scroll;
1610
- const timeDiff = newest.time - oldest.time;
1611
- velocity = timeDiff > 0 ? scrollDiff / timeDiff : 0;
1610
+ if (now - current.time > 1e3) {
1611
+ break;
1612
1612
  }
1613
+ oldest = current;
1613
1614
  }
1614
- return velocity;
1615
+ const scrollDiff = newest.scroll - oldest.scroll;
1616
+ const timeDiff = newest.time - oldest.time;
1617
+ return timeDiff > 0 ? scrollDiff / timeDiff : 0;
1615
1618
  };
1616
1619
 
1617
1620
  // src/utils/updateSnapToOffsets.ts
@@ -2770,7 +2773,6 @@ function onScroll(ctx, event) {
2770
2773
  return;
2771
2774
  }
2772
2775
  let newScroll = event.nativeEvent.contentOffset[state.props.horizontal ? "x" : "y"];
2773
- state.scrollPending = newScroll;
2774
2776
  if (state.scrollingTo) {
2775
2777
  const maxOffset = clampScrollOffset(ctx, newScroll);
2776
2778
  if (newScroll !== maxOffset && Math.abs(newScroll - maxOffset) > 1) {
@@ -2784,8 +2786,11 @@ function onScroll(ctx, event) {
2784
2786
  return;
2785
2787
  }
2786
2788
  }
2789
+ state.scrollPending = newScroll;
2787
2790
  updateScroll(ctx, newScroll);
2788
- checkFinishedScroll(ctx);
2791
+ if (state.scrollingTo) {
2792
+ checkFinishedScroll(ctx);
2793
+ }
2789
2794
  onScrollProp == null ? void 0 : onScrollProp(event);
2790
2795
  }
2791
2796
 
@@ -3139,6 +3144,24 @@ function getRenderedItem(ctx, key) {
3139
3144
  }
3140
3145
  return { index, item: data[index], renderedItem };
3141
3146
  }
3147
+
3148
+ // src/utils/normalizeMaintainVisibleContentPosition.ts
3149
+ function normalizeMaintainVisibleContentPosition(value) {
3150
+ var _a3, _b;
3151
+ if (value === true) {
3152
+ return { dataChanged: true, scroll: true };
3153
+ }
3154
+ if (value && typeof value === "object") {
3155
+ return {
3156
+ dataChanged: (_a3 = value.dataChanged) != null ? _a3 : false,
3157
+ scroll: (_b = value.scroll) != null ? _b : true
3158
+ };
3159
+ }
3160
+ if (value === false) {
3161
+ return { dataChanged: false, scroll: false };
3162
+ }
3163
+ return { dataChanged: false, scroll: true };
3164
+ }
3142
3165
  function useThrottleDebounce(mode) {
3143
3166
  const timeoutRef = useRef(null);
3144
3167
  const lastCallTimeRef = useRef(0);
@@ -3233,7 +3256,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3233
3256
  ListHeaderComponent,
3234
3257
  maintainScrollAtEnd = false,
3235
3258
  maintainScrollAtEndThreshold = 0.1,
3236
- maintainVisibleContentPosition = false,
3259
+ maintainVisibleContentPosition: maintainVisibleContentPositionProp,
3237
3260
  numColumns: numColumnsProp = 1,
3238
3261
  onEndReached,
3239
3262
  onEndReachedThreshold = 0.5,
@@ -3271,6 +3294,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3271
3294
  const style = { ...StyleSheet.flatten(styleProp) };
3272
3295
  const stylePaddingTopState = extractPadding(style, contentContainerStyle, "Top");
3273
3296
  const stylePaddingBottomState = extractPadding(style, contentContainerStyle, "Bottom");
3297
+ const maintainVisibleContentPositionConfig = normalizeMaintainVisibleContentPosition(
3298
+ maintainVisibleContentPositionProp
3299
+ );
3274
3300
  const [renderNum, setRenderNum] = useState(0);
3275
3301
  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;
3276
3302
  const [canRender, setCanRender] = React2.useState(!IsNewArchitecture);
@@ -3355,7 +3381,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3355
3381
  };
3356
3382
  const internalState = ctx.state;
3357
3383
  internalState.triggerCalculateItemsInView = (params) => calculateItemsInView(ctx, params);
3358
- set$(ctx, "maintainVisibleContentPosition", maintainVisibleContentPosition);
3384
+ set$(ctx, "maintainVisibleContentPosition", maintainVisibleContentPositionConfig);
3359
3385
  set$(ctx, "extraData", extraData);
3360
3386
  }
3361
3387
  refState.current = ctx.state;
@@ -3386,7 +3412,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3386
3412
  keyExtractor,
3387
3413
  maintainScrollAtEnd,
3388
3414
  maintainScrollAtEndThreshold,
3389
- maintainVisibleContentPosition,
3415
+ maintainVisibleContentPosition: maintainVisibleContentPositionConfig,
3390
3416
  numColumns: numColumnsProp,
3391
3417
  onEndReached,
3392
3418
  onEndReachedThreshold,
@@ -3421,7 +3447,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3421
3447
  setPaddingTop(ctx, { stylePaddingTop: stylePaddingTopState });
3422
3448
  refState.current.props.stylePaddingBottom = stylePaddingBottomState;
3423
3449
  let paddingDiff = stylePaddingTopState - prevPaddingTop;
3424
- if (paddingDiff && prevPaddingTop !== void 0 && Platform2.OS === "ios") {
3450
+ if (maintainVisibleContentPositionConfig.scroll && paddingDiff && prevPaddingTop !== void 0 && Platform2.OS === "ios") {
3425
3451
  if (state.scroll < 0) {
3426
3452
  paddingDiff += state.scroll;
3427
3453
  }
@@ -3466,7 +3492,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3466
3492
  value = 0;
3467
3493
  }
3468
3494
  if (!value) {
3469
- state.didFinishInitialScroll = true;
3495
+ setInitialRenderState(ctx, { didInitialScroll: true });
3470
3496
  }
3471
3497
  return value;
3472
3498
  }, [renderNum]);
@@ -3595,7 +3621,6 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3595
3621
  initialContentOffset,
3596
3622
  ListEmptyComponent: dataProp.length === 0 ? ListEmptyComponent : void 0,
3597
3623
  ListHeaderComponent,
3598
- maintainVisibleContentPosition,
3599
3624
  onLayout,
3600
3625
  onLayoutHeader,
3601
3626
  onMomentumScrollEnd: fns.onMomentumScrollEnd,
@@ -18,7 +18,7 @@ type ListenerTypeValueMap = {
18
18
  headerSize: number;
19
19
  lastItemKeys: string[];
20
20
  lastPositionUpdate: number;
21
- maintainVisibleContentPosition: boolean;
21
+ maintainVisibleContentPosition: MaintainVisibleContentPositionNormalized;
22
22
  numColumns: number;
23
23
  numContainers: number;
24
24
  numContainersPooled: number;
@@ -221,11 +221,13 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
221
221
  */
222
222
  maintainScrollAtEndThreshold?: number;
223
223
  /**
224
- * If true, maintains visibility of content across data changes (filtering/resorting/insertions).
225
- * Scroll-time stability for measurements is always enabled.
226
- * @default false
224
+ * Maintains visibility of content.
225
+ * - scroll (default: true) stabilizes during size/layout changes while scrolling.
226
+ * - dataChanged (default: false) stabilizes when the data array changes; passing true also sets the RN maintainVisibleContentPosition prop.
227
+ * - undefined (default) enables scroll stabilization but skips data-change anchoring.
228
+ * - true enables both behaviors; false disables both.
227
229
  */
228
- maintainVisibleContentPosition?: boolean;
230
+ maintainVisibleContentPosition?: boolean | MaintainVisibleContentPositionConfig;
229
231
  /**
230
232
  * Number of columns to render items in.
231
233
  * @default 1
@@ -343,6 +345,14 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
343
345
  itemsAreEqual?: (itemPrevious: ItemT, item: ItemT, index: number, data: readonly ItemT[]) => boolean;
344
346
  }
345
347
  type LegendListPropsBase<ItemT, TScrollView extends ComponentProps<typeof ScrollView> | ComponentProps<typeof Animated.ScrollView> | ComponentProps<typeof Reanimated.ScrollView>, TItemType extends string | undefined = string | undefined> = BaseScrollViewProps<TScrollView> & LegendListSpecificProps<ItemT, TItemType> & (DataModeProps<ItemT, TItemType> | ChildrenModeProps);
348
+ interface MaintainVisibleContentPositionConfig {
349
+ dataChanged?: boolean;
350
+ scroll?: boolean;
351
+ }
352
+ interface MaintainVisibleContentPositionNormalized {
353
+ dataChanged: boolean;
354
+ scroll: boolean;
355
+ }
346
356
  interface MaintainScrollAtEndOptions {
347
357
  onLayout?: boolean;
348
358
  onItemLayout?: boolean;
@@ -476,7 +486,7 @@ interface InternalState {
476
486
  keyExtractor: LegendListProps["keyExtractor"];
477
487
  maintainScrollAtEnd: boolean | MaintainScrollAtEndOptions;
478
488
  maintainScrollAtEndThreshold: number | undefined;
479
- maintainVisibleContentPosition: boolean;
489
+ maintainVisibleContentPosition: MaintainVisibleContentPositionNormalized;
480
490
  numColumns: number;
481
491
  onEndReached: LegendListProps["onEndReached"];
482
492
  onEndReachedThreshold: number | null | undefined;
@@ -721,4 +731,4 @@ type GetRenderedItemResult<ItemT> = {
721
731
  };
722
732
  type GetRenderedItem = (key: string) => GetRenderedItemResult<any> | null;
723
733
 
724
- export { type ColumnWrapperStyle as C, type GetRenderedItemResult as G, type InternalState as I, type LegendListProps as L, type MaintainScrollAtEndOptions as M, type OnViewableItemsChanged as O, type ScrollTarget as S, type ThresholdSnapshot as T, type ViewabilityCallback as V, type LegendListRef as a, type ViewabilityAmountCallback as b, type LegendListRecyclingState as c, type LegendListPropsBase as d, type ViewableRange as e, type LegendListRenderItemProps as f, type LegendListState as g, type ViewToken as h, type ViewAmountToken as i, type ViewabilityConfigCallbackPair as j, type ViewabilityConfigCallbackPairs as k, type ViewabilityConfig as l, type TypedForwardRef as m, type TypedMemo as n, typedMemo as o, type ScrollIndexWithOffset as p, type ScrollIndexWithOffsetPosition as q, type ScrollIndexWithOffsetAndContentOffset as r, type InitialScrollAnchor as s, typedForwardRef as t, type GetRenderedItem as u };
734
+ export { type ColumnWrapperStyle as C, type GetRenderedItemResult as G, type InternalState as I, type LegendListProps as L, type MaintainVisibleContentPositionConfig as M, type OnViewableItemsChanged as O, type ScrollTarget as S, type ThresholdSnapshot as T, type ViewabilityCallback as V, type LegendListRef as a, type ViewabilityAmountCallback as b, type LegendListRecyclingState as c, type LegendListPropsBase as d, type MaintainVisibleContentPositionNormalized as e, type MaintainScrollAtEndOptions as f, type ViewableRange as g, type LegendListRenderItemProps as h, type LegendListState as i, type ViewToken as j, type ViewAmountToken as k, type ViewabilityConfigCallbackPair as l, type ViewabilityConfigCallbackPairs as m, type ViewabilityConfig as n, type TypedForwardRef as o, type TypedMemo as p, typedMemo as q, type ScrollIndexWithOffset as r, type ScrollIndexWithOffsetPosition as s, typedForwardRef as t, type ScrollIndexWithOffsetAndContentOffset as u, type InitialScrollAnchor as v, type GetRenderedItem as w };
@@ -18,7 +18,7 @@ type ListenerTypeValueMap = {
18
18
  headerSize: number;
19
19
  lastItemKeys: string[];
20
20
  lastPositionUpdate: number;
21
- maintainVisibleContentPosition: boolean;
21
+ maintainVisibleContentPosition: MaintainVisibleContentPositionNormalized;
22
22
  numColumns: number;
23
23
  numContainers: number;
24
24
  numContainersPooled: number;
@@ -221,11 +221,13 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
221
221
  */
222
222
  maintainScrollAtEndThreshold?: number;
223
223
  /**
224
- * If true, maintains visibility of content across data changes (filtering/resorting/insertions).
225
- * Scroll-time stability for measurements is always enabled.
226
- * @default false
224
+ * Maintains visibility of content.
225
+ * - scroll (default: true) stabilizes during size/layout changes while scrolling.
226
+ * - dataChanged (default: false) stabilizes when the data array changes; passing true also sets the RN maintainVisibleContentPosition prop.
227
+ * - undefined (default) enables scroll stabilization but skips data-change anchoring.
228
+ * - true enables both behaviors; false disables both.
227
229
  */
228
- maintainVisibleContentPosition?: boolean;
230
+ maintainVisibleContentPosition?: boolean | MaintainVisibleContentPositionConfig;
229
231
  /**
230
232
  * Number of columns to render items in.
231
233
  * @default 1
@@ -343,6 +345,14 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
343
345
  itemsAreEqual?: (itemPrevious: ItemT, item: ItemT, index: number, data: readonly ItemT[]) => boolean;
344
346
  }
345
347
  type LegendListPropsBase<ItemT, TScrollView extends ComponentProps<typeof ScrollView> | ComponentProps<typeof Animated.ScrollView> | ComponentProps<typeof Reanimated.ScrollView>, TItemType extends string | undefined = string | undefined> = BaseScrollViewProps<TScrollView> & LegendListSpecificProps<ItemT, TItemType> & (DataModeProps<ItemT, TItemType> | ChildrenModeProps);
348
+ interface MaintainVisibleContentPositionConfig {
349
+ dataChanged?: boolean;
350
+ scroll?: boolean;
351
+ }
352
+ interface MaintainVisibleContentPositionNormalized {
353
+ dataChanged: boolean;
354
+ scroll: boolean;
355
+ }
346
356
  interface MaintainScrollAtEndOptions {
347
357
  onLayout?: boolean;
348
358
  onItemLayout?: boolean;
@@ -476,7 +486,7 @@ interface InternalState {
476
486
  keyExtractor: LegendListProps["keyExtractor"];
477
487
  maintainScrollAtEnd: boolean | MaintainScrollAtEndOptions;
478
488
  maintainScrollAtEndThreshold: number | undefined;
479
- maintainVisibleContentPosition: boolean;
489
+ maintainVisibleContentPosition: MaintainVisibleContentPositionNormalized;
480
490
  numColumns: number;
481
491
  onEndReached: LegendListProps["onEndReached"];
482
492
  onEndReachedThreshold: number | null | undefined;
@@ -721,4 +731,4 @@ type GetRenderedItemResult<ItemT> = {
721
731
  };
722
732
  type GetRenderedItem = (key: string) => GetRenderedItemResult<any> | null;
723
733
 
724
- export { type ColumnWrapperStyle as C, type GetRenderedItemResult as G, type InternalState as I, type LegendListProps as L, type MaintainScrollAtEndOptions as M, type OnViewableItemsChanged as O, type ScrollTarget as S, type ThresholdSnapshot as T, type ViewabilityCallback as V, type LegendListRef as a, type ViewabilityAmountCallback as b, type LegendListRecyclingState as c, type LegendListPropsBase as d, type ViewableRange as e, type LegendListRenderItemProps as f, type LegendListState as g, type ViewToken as h, type ViewAmountToken as i, type ViewabilityConfigCallbackPair as j, type ViewabilityConfigCallbackPairs as k, type ViewabilityConfig as l, type TypedForwardRef as m, type TypedMemo as n, typedMemo as o, type ScrollIndexWithOffset as p, type ScrollIndexWithOffsetPosition as q, type ScrollIndexWithOffsetAndContentOffset as r, type InitialScrollAnchor as s, typedForwardRef as t, type GetRenderedItem as u };
734
+ export { type ColumnWrapperStyle as C, type GetRenderedItemResult as G, type InternalState as I, type LegendListProps as L, type MaintainVisibleContentPositionConfig as M, type OnViewableItemsChanged as O, type ScrollTarget as S, type ThresholdSnapshot as T, type ViewabilityCallback as V, type LegendListRef as a, type ViewabilityAmountCallback as b, type LegendListRecyclingState as c, type LegendListPropsBase as d, type MaintainVisibleContentPositionNormalized as e, type MaintainScrollAtEndOptions as f, type ViewableRange as g, type LegendListRenderItemProps as h, type LegendListState as i, type ViewToken as j, type ViewAmountToken as k, type ViewabilityConfigCallbackPair as l, type ViewabilityConfigCallbackPairs as m, type ViewabilityConfig as n, type TypedForwardRef as o, type TypedMemo as p, typedMemo as q, type ScrollIndexWithOffset as r, type ScrollIndexWithOffsetPosition as s, typedForwardRef as t, type ScrollIndexWithOffsetAndContentOffset as u, type InitialScrollAnchor as v, type GetRenderedItem as w };