@legendapp/list 3.1.0 → 3.1.2

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/react.js CHANGED
@@ -1855,6 +1855,67 @@ function WebAnchoredEndSpace({ horizontal }) {
1855
1855
  return /* @__PURE__ */ React3__namespace.createElement("div", { style }, null);
1856
1856
  }
1857
1857
 
1858
+ // src/core/doMaintainScrollAtEnd.ts
1859
+ function doMaintainScrollAtEnd(ctx) {
1860
+ const state = ctx.state;
1861
+ const {
1862
+ didContainersLayout,
1863
+ pendingNativeMVCPAdjust,
1864
+ refScroller,
1865
+ props: { maintainScrollAtEnd }
1866
+ } = state;
1867
+ const isWithinMaintainScrollAtEndThreshold = peek$(ctx, "isWithinMaintainScrollAtEndThreshold");
1868
+ const shouldMaintainScrollAtEnd = !!(isWithinMaintainScrollAtEndThreshold && maintainScrollAtEnd && didContainersLayout);
1869
+ if (pendingNativeMVCPAdjust) {
1870
+ state.pendingMaintainScrollAtEnd = shouldMaintainScrollAtEnd;
1871
+ return false;
1872
+ }
1873
+ state.pendingMaintainScrollAtEnd = false;
1874
+ if (shouldMaintainScrollAtEnd) {
1875
+ const contentSize = getContentSize(ctx);
1876
+ if (contentSize < state.scrollLength) {
1877
+ state.scroll = 0;
1878
+ }
1879
+ if (!state.maintainingScrollAtEnd) {
1880
+ const pendingState = maintainScrollAtEnd.animated ? "pending-animated" : "pending-instant";
1881
+ const activeState = maintainScrollAtEnd.animated ? "animated" : "instant";
1882
+ state.maintainingScrollAtEnd = pendingState;
1883
+ requestAnimationFrame(() => {
1884
+ if (peek$(ctx, "isWithinMaintainScrollAtEndThreshold")) {
1885
+ state.maintainingScrollAtEnd = activeState;
1886
+ const scroller = refScroller.current;
1887
+ if (state.props.horizontal && isHorizontalRTL(state)) {
1888
+ const currentContentSize = getContentSize(ctx);
1889
+ const logicalEndOffset = getLogicalHorizontalMaxOffset(state, currentContentSize);
1890
+ const nativeOffset = toNativeHorizontalOffset(state, logicalEndOffset, currentContentSize);
1891
+ scroller == null ? void 0 : scroller.scrollTo({
1892
+ animated: maintainScrollAtEnd.animated,
1893
+ x: nativeOffset,
1894
+ y: 0
1895
+ });
1896
+ } else {
1897
+ scroller == null ? void 0 : scroller.scrollToEnd({
1898
+ animated: maintainScrollAtEnd.animated
1899
+ });
1900
+ }
1901
+ setTimeout(
1902
+ () => {
1903
+ if (state.maintainingScrollAtEnd === activeState) {
1904
+ state.maintainingScrollAtEnd = void 0;
1905
+ }
1906
+ },
1907
+ maintainScrollAtEnd.animated ? 500 : 0
1908
+ );
1909
+ } else if (state.maintainingScrollAtEnd === pendingState) {
1910
+ state.maintainingScrollAtEnd = void 0;
1911
+ }
1912
+ });
1913
+ }
1914
+ return true;
1915
+ }
1916
+ return false;
1917
+ }
1918
+
1858
1919
  // src/core/updateContentMetricsState.ts
1859
1920
  function getRawContentLength(ctx) {
1860
1921
  var _a3, _b, _c;
@@ -2269,8 +2330,11 @@ function updateAdaptiveRender(ctx, scrollVelocity) {
2269
2330
  // src/utils/getEffectiveDrawDistance.ts
2270
2331
  var INITIAL_DRAW_DISTANCE = 100;
2271
2332
  function getEffectiveDrawDistance(ctx) {
2333
+ var _a3;
2272
2334
  const drawDistance = ctx.state.props.drawDistance;
2273
- return peek$(ctx, "readyToRender") ? drawDistance : Math.min(drawDistance, INITIAL_DRAW_DISTANCE);
2335
+ const initialScroll = ctx.state.initialScroll;
2336
+ const needsFullInitialDrawDistance = initialScroll !== void 0 && ((_a3 = initialScroll.viewPosition) != null ? _a3 : 0) > 0;
2337
+ return peek$(ctx, "readyToRender") || needsFullInitialDrawDistance ? drawDistance : Math.min(drawDistance, INITIAL_DRAW_DISTANCE);
2274
2338
  }
2275
2339
 
2276
2340
  // src/utils/setInitialRenderState.ts
@@ -2522,10 +2586,12 @@ function requestAdjust(ctx, positionDiff, dataChanged) {
2522
2586
  // src/core/updateContentMetrics.ts
2523
2587
  var SCROLL_ADJUST_EPSILON = 0.1;
2524
2588
  function setContentLengthSignal(ctx, signalName, size) {
2525
- if (peek$(ctx, signalName) !== size) {
2589
+ const didChange = peek$(ctx, signalName) !== size;
2590
+ if (didChange) {
2526
2591
  set$(ctx, signalName, size);
2527
2592
  updateContentMetricsState(ctx);
2528
2593
  }
2594
+ return didChange;
2529
2595
  }
2530
2596
  function shouldAdjustForHeaderSizeChange(ctx, previousHeaderSize, nextHeaderSize) {
2531
2597
  const { didContainersLayout, didFinishInitialScroll, props, scroll, scrollingTo } = ctx.state;
@@ -2549,7 +2615,7 @@ function setHeaderSize(ctx, size) {
2549
2615
  state.didMeasureHeader = true;
2550
2616
  }
2551
2617
  function setFooterSize(ctx, size) {
2552
- setContentLengthSignal(ctx, "footerSize", size);
2618
+ return setContentLengthSignal(ctx, "footerSize", size);
2553
2619
  }
2554
2620
  function areInsetsEqual(left, right) {
2555
2621
  var _a3, _b, _c, _d, _e, _f, _g, _h;
@@ -2643,14 +2709,25 @@ var ListComponent = typedMemo(function ListComponent2({
2643
2709
  );
2644
2710
  const ScrollComponent = renderScrollComponent ? CustomScrollComponent : ListComponentScrollView;
2645
2711
  const SnapOrScroll = snapToIndices ? SnapWrapper : ScrollComponent;
2712
+ const updateFooterSize = React3.useCallback(
2713
+ (size, afterSizeUpdate) => {
2714
+ var _a3;
2715
+ const didFooterSizeChange = setFooterSize(ctx, size);
2716
+ afterSizeUpdate == null ? void 0 : afterSizeUpdate();
2717
+ if (didFooterSizeChange && ((_a3 = ctx.state.props.maintainScrollAtEnd) == null ? void 0 : _a3.onFooterLayout)) {
2718
+ doMaintainScrollAtEnd(ctx);
2719
+ }
2720
+ },
2721
+ [ctx]
2722
+ );
2646
2723
  React3.useLayoutEffect(() => {
2647
2724
  if (!ListHeaderComponent) {
2648
2725
  setHeaderSize(ctx, 0);
2649
2726
  }
2650
2727
  if (!ListFooterComponent) {
2651
- setFooterSize(ctx, 0);
2728
+ updateFooterSize(0);
2652
2729
  }
2653
- }, [ListHeaderComponent, ListFooterComponent, ctx]);
2730
+ }, [ListHeaderComponent, ListFooterComponent, ctx, updateFooterSize]);
2654
2731
  const onLayoutHeader = React3.useCallback(
2655
2732
  (rect) => {
2656
2733
  const size = rect[horizontal ? "width" : "height"];
@@ -2661,10 +2738,11 @@ var ListComponent = typedMemo(function ListComponent2({
2661
2738
  const onLayoutFooterInternal = React3.useCallback(
2662
2739
  (rect, fromLayoutEffect) => {
2663
2740
  const size = rect[horizontal ? "width" : "height"];
2664
- setFooterSize(ctx, size);
2665
- onLayoutFooter == null ? void 0 : onLayoutFooter(rect, fromLayoutEffect);
2741
+ updateFooterSize(size, () => {
2742
+ onLayoutFooter == null ? void 0 : onLayoutFooter(rect, fromLayoutEffect);
2743
+ });
2666
2744
  },
2667
- [ctx, horizontal, onLayoutFooter]
2745
+ [horizontal, onLayoutFooter, updateFooterSize]
2668
2746
  );
2669
2747
  return /* @__PURE__ */ React3__namespace.createElement(
2670
2748
  SnapOrScroll,
@@ -2936,67 +3014,6 @@ function clampScrollOffset(ctx, offset, scrollTarget) {
2936
3014
  return clampedOffset;
2937
3015
  }
2938
3016
 
2939
- // src/core/doMaintainScrollAtEnd.ts
2940
- function doMaintainScrollAtEnd(ctx) {
2941
- const state = ctx.state;
2942
- const {
2943
- didContainersLayout,
2944
- pendingNativeMVCPAdjust,
2945
- refScroller,
2946
- props: { maintainScrollAtEnd }
2947
- } = state;
2948
- const isWithinMaintainScrollAtEndThreshold = peek$(ctx, "isWithinMaintainScrollAtEndThreshold");
2949
- const shouldMaintainScrollAtEnd = !!(isWithinMaintainScrollAtEndThreshold && maintainScrollAtEnd && didContainersLayout);
2950
- if (pendingNativeMVCPAdjust) {
2951
- state.pendingMaintainScrollAtEnd = shouldMaintainScrollAtEnd;
2952
- return false;
2953
- }
2954
- state.pendingMaintainScrollAtEnd = false;
2955
- if (shouldMaintainScrollAtEnd) {
2956
- const contentSize = getContentSize(ctx);
2957
- if (contentSize < state.scrollLength) {
2958
- state.scroll = 0;
2959
- }
2960
- if (!state.maintainingScrollAtEnd) {
2961
- const pendingState = maintainScrollAtEnd.animated ? "pending-animated" : "pending-instant";
2962
- const activeState = maintainScrollAtEnd.animated ? "animated" : "instant";
2963
- state.maintainingScrollAtEnd = pendingState;
2964
- requestAnimationFrame(() => {
2965
- if (peek$(ctx, "isWithinMaintainScrollAtEndThreshold")) {
2966
- state.maintainingScrollAtEnd = activeState;
2967
- const scroller = refScroller.current;
2968
- if (state.props.horizontal && isHorizontalRTL(state)) {
2969
- const currentContentSize = getContentSize(ctx);
2970
- const logicalEndOffset = getLogicalHorizontalMaxOffset(state, currentContentSize);
2971
- const nativeOffset = toNativeHorizontalOffset(state, logicalEndOffset, currentContentSize);
2972
- scroller == null ? void 0 : scroller.scrollTo({
2973
- animated: maintainScrollAtEnd.animated,
2974
- x: nativeOffset,
2975
- y: 0
2976
- });
2977
- } else {
2978
- scroller == null ? void 0 : scroller.scrollToEnd({
2979
- animated: maintainScrollAtEnd.animated
2980
- });
2981
- }
2982
- setTimeout(
2983
- () => {
2984
- if (state.maintainingScrollAtEnd === activeState) {
2985
- state.maintainingScrollAtEnd = void 0;
2986
- }
2987
- },
2988
- maintainScrollAtEnd.animated ? 500 : 0
2989
- );
2990
- } else if (state.maintainingScrollAtEnd === pendingState) {
2991
- state.maintainingScrollAtEnd = void 0;
2992
- }
2993
- });
2994
- }
2995
- return true;
2996
- }
2997
- return false;
2998
- }
2999
-
3000
3017
  // src/core/mvcp.ts
3001
3018
  var MVCP_POSITION_EPSILON = 0.1;
3002
3019
  var MVCP_ANCHOR_LOCK_TTL_MS = 300;
@@ -3237,6 +3254,9 @@ function prepareMVCP(ctx, dataChanged) {
3237
3254
  if (diff > 0) {
3238
3255
  diff = Math.max(0, totalSize - state.scroll - state.scrollLength);
3239
3256
  } else {
3257
+ const maxScroll = Math.max(0, totalSize - state.scrollLength);
3258
+ state.scroll = maxScroll;
3259
+ state.scrollPending = maxScroll;
3240
3260
  diff = 0;
3241
3261
  }
3242
3262
  }
@@ -5584,7 +5604,7 @@ function calculateItemsInView(ctx, params = {}) {
5584
5604
  const scrollAdjustPendingBeforeMVCP = (_f = peek$(ctx, "scrollAdjustPending")) != null ? _f : 0;
5585
5605
  checkMVCP == null ? void 0 : checkMVCP();
5586
5606
  const didMVCPAdjustScroll = !!checkMVCP && (state.scroll !== scrollBeforeMVCP || ((_g = peek$(ctx, "scrollAdjustPending")) != null ? _g : 0) !== scrollAdjustPendingBeforeMVCP);
5587
- if (didMVCPAdjustScroll && initialScroll) {
5607
+ if (didMVCPAdjustScroll && (initialScroll || state.scrollingTo)) {
5588
5608
  updateScroll2(state.scroll);
5589
5609
  updateScrollRange();
5590
5610
  }
@@ -6820,12 +6840,13 @@ function getRenderedItem(ctx, key) {
6820
6840
 
6821
6841
  // src/utils/normalizeMaintainScrollAtEnd.ts
6822
6842
  function normalizeMaintainScrollAtEndOn(on, hasExplicitOn) {
6823
- var _a3, _b, _c;
6843
+ var _a3, _b, _c, _d;
6824
6844
  return {
6825
6845
  animated: false,
6826
6846
  onDataChange: hasExplicitOn ? (_a3 = on == null ? void 0 : on.dataChange) != null ? _a3 : false : true,
6827
- onItemLayout: hasExplicitOn ? (_b = on == null ? void 0 : on.itemLayout) != null ? _b : false : true,
6828
- onLayout: hasExplicitOn ? (_c = on == null ? void 0 : on.layout) != null ? _c : false : true
6847
+ onFooterLayout: hasExplicitOn ? (_b = on == null ? void 0 : on.footerLayout) != null ? _b : false : true,
6848
+ onItemLayout: hasExplicitOn ? (_c = on == null ? void 0 : on.itemLayout) != null ? _c : false : true,
6849
+ onLayout: hasExplicitOn ? (_d = on == null ? void 0 : on.layout) != null ? _d : false : true
6829
6850
  };
6830
6851
  }
6831
6852
  function normalizeMaintainScrollAtEnd(value) {
package/react.mjs CHANGED
@@ -1834,6 +1834,67 @@ function WebAnchoredEndSpace({ horizontal }) {
1834
1834
  return /* @__PURE__ */ React3.createElement("div", { style }, null);
1835
1835
  }
1836
1836
 
1837
+ // src/core/doMaintainScrollAtEnd.ts
1838
+ function doMaintainScrollAtEnd(ctx) {
1839
+ const state = ctx.state;
1840
+ const {
1841
+ didContainersLayout,
1842
+ pendingNativeMVCPAdjust,
1843
+ refScroller,
1844
+ props: { maintainScrollAtEnd }
1845
+ } = state;
1846
+ const isWithinMaintainScrollAtEndThreshold = peek$(ctx, "isWithinMaintainScrollAtEndThreshold");
1847
+ const shouldMaintainScrollAtEnd = !!(isWithinMaintainScrollAtEndThreshold && maintainScrollAtEnd && didContainersLayout);
1848
+ if (pendingNativeMVCPAdjust) {
1849
+ state.pendingMaintainScrollAtEnd = shouldMaintainScrollAtEnd;
1850
+ return false;
1851
+ }
1852
+ state.pendingMaintainScrollAtEnd = false;
1853
+ if (shouldMaintainScrollAtEnd) {
1854
+ const contentSize = getContentSize(ctx);
1855
+ if (contentSize < state.scrollLength) {
1856
+ state.scroll = 0;
1857
+ }
1858
+ if (!state.maintainingScrollAtEnd) {
1859
+ const pendingState = maintainScrollAtEnd.animated ? "pending-animated" : "pending-instant";
1860
+ const activeState = maintainScrollAtEnd.animated ? "animated" : "instant";
1861
+ state.maintainingScrollAtEnd = pendingState;
1862
+ requestAnimationFrame(() => {
1863
+ if (peek$(ctx, "isWithinMaintainScrollAtEndThreshold")) {
1864
+ state.maintainingScrollAtEnd = activeState;
1865
+ const scroller = refScroller.current;
1866
+ if (state.props.horizontal && isHorizontalRTL(state)) {
1867
+ const currentContentSize = getContentSize(ctx);
1868
+ const logicalEndOffset = getLogicalHorizontalMaxOffset(state, currentContentSize);
1869
+ const nativeOffset = toNativeHorizontalOffset(state, logicalEndOffset, currentContentSize);
1870
+ scroller == null ? void 0 : scroller.scrollTo({
1871
+ animated: maintainScrollAtEnd.animated,
1872
+ x: nativeOffset,
1873
+ y: 0
1874
+ });
1875
+ } else {
1876
+ scroller == null ? void 0 : scroller.scrollToEnd({
1877
+ animated: maintainScrollAtEnd.animated
1878
+ });
1879
+ }
1880
+ setTimeout(
1881
+ () => {
1882
+ if (state.maintainingScrollAtEnd === activeState) {
1883
+ state.maintainingScrollAtEnd = void 0;
1884
+ }
1885
+ },
1886
+ maintainScrollAtEnd.animated ? 500 : 0
1887
+ );
1888
+ } else if (state.maintainingScrollAtEnd === pendingState) {
1889
+ state.maintainingScrollAtEnd = void 0;
1890
+ }
1891
+ });
1892
+ }
1893
+ return true;
1894
+ }
1895
+ return false;
1896
+ }
1897
+
1837
1898
  // src/core/updateContentMetricsState.ts
1838
1899
  function getRawContentLength(ctx) {
1839
1900
  var _a3, _b, _c;
@@ -2248,8 +2309,11 @@ function updateAdaptiveRender(ctx, scrollVelocity) {
2248
2309
  // src/utils/getEffectiveDrawDistance.ts
2249
2310
  var INITIAL_DRAW_DISTANCE = 100;
2250
2311
  function getEffectiveDrawDistance(ctx) {
2312
+ var _a3;
2251
2313
  const drawDistance = ctx.state.props.drawDistance;
2252
- return peek$(ctx, "readyToRender") ? drawDistance : Math.min(drawDistance, INITIAL_DRAW_DISTANCE);
2314
+ const initialScroll = ctx.state.initialScroll;
2315
+ const needsFullInitialDrawDistance = initialScroll !== void 0 && ((_a3 = initialScroll.viewPosition) != null ? _a3 : 0) > 0;
2316
+ return peek$(ctx, "readyToRender") || needsFullInitialDrawDistance ? drawDistance : Math.min(drawDistance, INITIAL_DRAW_DISTANCE);
2253
2317
  }
2254
2318
 
2255
2319
  // src/utils/setInitialRenderState.ts
@@ -2501,10 +2565,12 @@ function requestAdjust(ctx, positionDiff, dataChanged) {
2501
2565
  // src/core/updateContentMetrics.ts
2502
2566
  var SCROLL_ADJUST_EPSILON = 0.1;
2503
2567
  function setContentLengthSignal(ctx, signalName, size) {
2504
- if (peek$(ctx, signalName) !== size) {
2568
+ const didChange = peek$(ctx, signalName) !== size;
2569
+ if (didChange) {
2505
2570
  set$(ctx, signalName, size);
2506
2571
  updateContentMetricsState(ctx);
2507
2572
  }
2573
+ return didChange;
2508
2574
  }
2509
2575
  function shouldAdjustForHeaderSizeChange(ctx, previousHeaderSize, nextHeaderSize) {
2510
2576
  const { didContainersLayout, didFinishInitialScroll, props, scroll, scrollingTo } = ctx.state;
@@ -2528,7 +2594,7 @@ function setHeaderSize(ctx, size) {
2528
2594
  state.didMeasureHeader = true;
2529
2595
  }
2530
2596
  function setFooterSize(ctx, size) {
2531
- setContentLengthSignal(ctx, "footerSize", size);
2597
+ return setContentLengthSignal(ctx, "footerSize", size);
2532
2598
  }
2533
2599
  function areInsetsEqual(left, right) {
2534
2600
  var _a3, _b, _c, _d, _e, _f, _g, _h;
@@ -2622,14 +2688,25 @@ var ListComponent = typedMemo(function ListComponent2({
2622
2688
  );
2623
2689
  const ScrollComponent = renderScrollComponent ? CustomScrollComponent : ListComponentScrollView;
2624
2690
  const SnapOrScroll = snapToIndices ? SnapWrapper : ScrollComponent;
2691
+ const updateFooterSize = useCallback(
2692
+ (size, afterSizeUpdate) => {
2693
+ var _a3;
2694
+ const didFooterSizeChange = setFooterSize(ctx, size);
2695
+ afterSizeUpdate == null ? void 0 : afterSizeUpdate();
2696
+ if (didFooterSizeChange && ((_a3 = ctx.state.props.maintainScrollAtEnd) == null ? void 0 : _a3.onFooterLayout)) {
2697
+ doMaintainScrollAtEnd(ctx);
2698
+ }
2699
+ },
2700
+ [ctx]
2701
+ );
2625
2702
  useLayoutEffect(() => {
2626
2703
  if (!ListHeaderComponent) {
2627
2704
  setHeaderSize(ctx, 0);
2628
2705
  }
2629
2706
  if (!ListFooterComponent) {
2630
- setFooterSize(ctx, 0);
2707
+ updateFooterSize(0);
2631
2708
  }
2632
- }, [ListHeaderComponent, ListFooterComponent, ctx]);
2709
+ }, [ListHeaderComponent, ListFooterComponent, ctx, updateFooterSize]);
2633
2710
  const onLayoutHeader = useCallback(
2634
2711
  (rect) => {
2635
2712
  const size = rect[horizontal ? "width" : "height"];
@@ -2640,10 +2717,11 @@ var ListComponent = typedMemo(function ListComponent2({
2640
2717
  const onLayoutFooterInternal = useCallback(
2641
2718
  (rect, fromLayoutEffect) => {
2642
2719
  const size = rect[horizontal ? "width" : "height"];
2643
- setFooterSize(ctx, size);
2644
- onLayoutFooter == null ? void 0 : onLayoutFooter(rect, fromLayoutEffect);
2720
+ updateFooterSize(size, () => {
2721
+ onLayoutFooter == null ? void 0 : onLayoutFooter(rect, fromLayoutEffect);
2722
+ });
2645
2723
  },
2646
- [ctx, horizontal, onLayoutFooter]
2724
+ [horizontal, onLayoutFooter, updateFooterSize]
2647
2725
  );
2648
2726
  return /* @__PURE__ */ React3.createElement(
2649
2727
  SnapOrScroll,
@@ -2915,67 +2993,6 @@ function clampScrollOffset(ctx, offset, scrollTarget) {
2915
2993
  return clampedOffset;
2916
2994
  }
2917
2995
 
2918
- // src/core/doMaintainScrollAtEnd.ts
2919
- function doMaintainScrollAtEnd(ctx) {
2920
- const state = ctx.state;
2921
- const {
2922
- didContainersLayout,
2923
- pendingNativeMVCPAdjust,
2924
- refScroller,
2925
- props: { maintainScrollAtEnd }
2926
- } = state;
2927
- const isWithinMaintainScrollAtEndThreshold = peek$(ctx, "isWithinMaintainScrollAtEndThreshold");
2928
- const shouldMaintainScrollAtEnd = !!(isWithinMaintainScrollAtEndThreshold && maintainScrollAtEnd && didContainersLayout);
2929
- if (pendingNativeMVCPAdjust) {
2930
- state.pendingMaintainScrollAtEnd = shouldMaintainScrollAtEnd;
2931
- return false;
2932
- }
2933
- state.pendingMaintainScrollAtEnd = false;
2934
- if (shouldMaintainScrollAtEnd) {
2935
- const contentSize = getContentSize(ctx);
2936
- if (contentSize < state.scrollLength) {
2937
- state.scroll = 0;
2938
- }
2939
- if (!state.maintainingScrollAtEnd) {
2940
- const pendingState = maintainScrollAtEnd.animated ? "pending-animated" : "pending-instant";
2941
- const activeState = maintainScrollAtEnd.animated ? "animated" : "instant";
2942
- state.maintainingScrollAtEnd = pendingState;
2943
- requestAnimationFrame(() => {
2944
- if (peek$(ctx, "isWithinMaintainScrollAtEndThreshold")) {
2945
- state.maintainingScrollAtEnd = activeState;
2946
- const scroller = refScroller.current;
2947
- if (state.props.horizontal && isHorizontalRTL(state)) {
2948
- const currentContentSize = getContentSize(ctx);
2949
- const logicalEndOffset = getLogicalHorizontalMaxOffset(state, currentContentSize);
2950
- const nativeOffset = toNativeHorizontalOffset(state, logicalEndOffset, currentContentSize);
2951
- scroller == null ? void 0 : scroller.scrollTo({
2952
- animated: maintainScrollAtEnd.animated,
2953
- x: nativeOffset,
2954
- y: 0
2955
- });
2956
- } else {
2957
- scroller == null ? void 0 : scroller.scrollToEnd({
2958
- animated: maintainScrollAtEnd.animated
2959
- });
2960
- }
2961
- setTimeout(
2962
- () => {
2963
- if (state.maintainingScrollAtEnd === activeState) {
2964
- state.maintainingScrollAtEnd = void 0;
2965
- }
2966
- },
2967
- maintainScrollAtEnd.animated ? 500 : 0
2968
- );
2969
- } else if (state.maintainingScrollAtEnd === pendingState) {
2970
- state.maintainingScrollAtEnd = void 0;
2971
- }
2972
- });
2973
- }
2974
- return true;
2975
- }
2976
- return false;
2977
- }
2978
-
2979
2996
  // src/core/mvcp.ts
2980
2997
  var MVCP_POSITION_EPSILON = 0.1;
2981
2998
  var MVCP_ANCHOR_LOCK_TTL_MS = 300;
@@ -3216,6 +3233,9 @@ function prepareMVCP(ctx, dataChanged) {
3216
3233
  if (diff > 0) {
3217
3234
  diff = Math.max(0, totalSize - state.scroll - state.scrollLength);
3218
3235
  } else {
3236
+ const maxScroll = Math.max(0, totalSize - state.scrollLength);
3237
+ state.scroll = maxScroll;
3238
+ state.scrollPending = maxScroll;
3219
3239
  diff = 0;
3220
3240
  }
3221
3241
  }
@@ -5563,7 +5583,7 @@ function calculateItemsInView(ctx, params = {}) {
5563
5583
  const scrollAdjustPendingBeforeMVCP = (_f = peek$(ctx, "scrollAdjustPending")) != null ? _f : 0;
5564
5584
  checkMVCP == null ? void 0 : checkMVCP();
5565
5585
  const didMVCPAdjustScroll = !!checkMVCP && (state.scroll !== scrollBeforeMVCP || ((_g = peek$(ctx, "scrollAdjustPending")) != null ? _g : 0) !== scrollAdjustPendingBeforeMVCP);
5566
- if (didMVCPAdjustScroll && initialScroll) {
5586
+ if (didMVCPAdjustScroll && (initialScroll || state.scrollingTo)) {
5567
5587
  updateScroll2(state.scroll);
5568
5588
  updateScrollRange();
5569
5589
  }
@@ -6799,12 +6819,13 @@ function getRenderedItem(ctx, key) {
6799
6819
 
6800
6820
  // src/utils/normalizeMaintainScrollAtEnd.ts
6801
6821
  function normalizeMaintainScrollAtEndOn(on, hasExplicitOn) {
6802
- var _a3, _b, _c;
6822
+ var _a3, _b, _c, _d;
6803
6823
  return {
6804
6824
  animated: false,
6805
6825
  onDataChange: hasExplicitOn ? (_a3 = on == null ? void 0 : on.dataChange) != null ? _a3 : false : true,
6806
- onItemLayout: hasExplicitOn ? (_b = on == null ? void 0 : on.itemLayout) != null ? _b : false : true,
6807
- onLayout: hasExplicitOn ? (_c = on == null ? void 0 : on.layout) != null ? _c : false : true
6826
+ onFooterLayout: hasExplicitOn ? (_b = on == null ? void 0 : on.footerLayout) != null ? _b : false : true,
6827
+ onItemLayout: hasExplicitOn ? (_c = on == null ? void 0 : on.itemLayout) != null ? _c : false : true,
6828
+ onLayout: hasExplicitOn ? (_d = on == null ? void 0 : on.layout) != null ? _d : false : true
6808
6829
  };
6809
6830
  }
6810
6831
  function normalizeMaintainScrollAtEnd(value) {
package/reanimated.d.ts CHANGED
@@ -461,6 +461,7 @@ interface AlwaysRenderConfig {
461
461
  }
462
462
  interface MaintainScrollAtEndOnOptions {
463
463
  dataChange?: boolean;
464
+ footerLayout?: boolean;
464
465
  itemLayout?: boolean;
465
466
  layout?: boolean;
466
467
  }
package/section-list.d.ts CHANGED
@@ -517,6 +517,7 @@ interface AlwaysRenderConfig {
517
517
  }
518
518
  interface MaintainScrollAtEndOnOptions {
519
519
  dataChange?: boolean;
520
+ footerLayout?: boolean;
520
521
  itemLayout?: boolean;
521
522
  layout?: boolean;
522
523
  }