Allow overriding the horizontal scroll position restore (#54115)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54115

Horizontal scroll view extensions should be able to  customize the scrolling behavior for state restores. This adds the `restoreScrollTo` function that will be called to restore the scroll position to the location provided by the shadow node state.

Changelog: [Internal]

Reviewed By: rozele

Differential Revision: D84310601

fbshipit-source-id: 007caa3d0922a5430ffc6f970eebb180a112f894
This commit is contained in:
Nick Lefever
2025-10-09 20:59:18 -07:00
committed by meta-codesync[bot]
parent 78bdf584e2
commit e926ad0428
2 changed files with 6 additions and 1 deletions
@@ -5618,6 +5618,7 @@ public class com/facebook/react/views/scroll/ReactHorizontalScrollView : android
public fun pageScroll (I)Z
public fun reactSmoothScrollTo (II)V
public fun requestChildFocus (Landroid/view/View;Landroid/view/View;)V
protected fun restoreScrollTo (II)V
public fun scrollTo (II)V
public fun scrollToPreservingMomentum (II)V
public fun setBackgroundColor (I)V
@@ -1660,10 +1660,14 @@ public class ReactHorizontalScrollView extends HorizontalScrollView
if (ReactNativeFeatureFlags.enableViewCulling()
|| ReactNativeFeatureFlags.useTraitHiddenOnAndroid()) {
Point scrollPosition = scrollState.getLastStateUpdateScroll();
scrollTo(scrollPosition.x, scrollPosition.y);
restoreScrollTo(scrollPosition.x, scrollPosition.y);
}
}
protected void restoreScrollTo(int x, int y) {
scrollTo(x, y);
}
@Override
public ReactScrollViewScrollState getReactScrollViewScrollState() {
return mReactScrollViewScrollState;