Skip to content

Commit a8fc5ff

Browse files
committed
fix(iOS): reset zoomScale before contentOffset when recycling ScrollView
1 parent da651fd commit a8fc5ff

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -692,9 +692,11 @@ - (void)prepareForRecycle
692692
_state.reset();
693693

694694
const auto &props = static_cast<const ScrollViewProps &>(*_props);
695-
_scrollView.contentOffset = RCTCGPointFromPoint(props.contentOffset);
696-
// Reset zoom scale to default
695+
// Reset zoom scale to default. This must happen before resetting contentOffset:
696+
// in RTL the mirroring transform makes UIKit report zoomScale == -1, and changing
697+
// it to 1 makes UIKit move contentOffset.
697698
_scrollView.zoomScale = 1.0;
699+
_scrollView.contentOffset = RCTCGPointFromPoint(props.contentOffset);
698700
// Invalidate cached content size so that updateState: recalculates the
699701
// container frame after zoomScale reset (which may have mutated it in RTL).
700702
_contentSize = CGSizeZero;

0 commit comments

Comments
 (0)