Skip to content

Commit e926ad0

Browse files
Nick Lefevermeta-codesync[bot]
authored andcommitted
Allow overriding the horizontal scroll position restore (#54115)
Summary: Pull Request resolved: #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
1 parent 78bdf58 commit e926ad0

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

packages/react-native/ReactAndroid/api/ReactAndroid.api

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5618,6 +5618,7 @@ public class com/facebook/react/views/scroll/ReactHorizontalScrollView : android
56185618
public fun pageScroll (I)Z
56195619
public fun reactSmoothScrollTo (II)V
56205620
public fun requestChildFocus (Landroid/view/View;Landroid/view/View;)V
5621+
protected fun restoreScrollTo (II)V
56215622
public fun scrollTo (II)V
56225623
public fun scrollToPreservingMomentum (II)V
56235624
public fun setBackgroundColor (I)V

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1660,10 +1660,14 @@ public void setReactScrollViewScrollState(ReactScrollViewScrollState scrollState
16601660
if (ReactNativeFeatureFlags.enableViewCulling()
16611661
|| ReactNativeFeatureFlags.useTraitHiddenOnAndroid()) {
16621662
Point scrollPosition = scrollState.getLastStateUpdateScroll();
1663-
scrollTo(scrollPosition.x, scrollPosition.y);
1663+
restoreScrollTo(scrollPosition.x, scrollPosition.y);
16641664
}
16651665
}
16661666

1667+
protected void restoreScrollTo(int x, int y) {
1668+
scrollTo(x, y);
1669+
}
1670+
16671671
@Override
16681672
public ReactScrollViewScrollState getReactScrollViewScrollState() {
16691673
return mReactScrollViewScrollState;

0 commit comments

Comments
 (0)