Fix bad comparison in RCTScrollViewComponentView RTL (#39030)

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

D29164056 fixed `scrollTo` coordinate space in RTL, but D38499666 regressed it by adding a comparison before the RTL conversion happens.

This makes `scrollTo` no-op if we are scrolling from the beginning to the end of the list, since the end of the list is `x: 0` in cartesian coordinates, and the start of the list is `x: 0` in flow-relative coordinates.

Do coordinate conversion before the early exit check.

Changelog:
[iOS][Fixed] - Fix bad comparison in RCTScrollViewComponentView RTL

Reviewed By: rshest

Differential Revision: D48378414

fbshipit-source-id: 14b0b9bb3b22828c290bbbc93b907d8c0e264995
This commit is contained in:
Nick Gerleman
2023-08-16 16:35:52 -07:00
committed by Facebook GitHub Bot
parent 676676c954
commit 65b7680720
@@ -675,17 +675,17 @@ static void RCTSendScrollEventForNativeAnimations_DEPRECATED(UIScrollView *scrol
- (void)scrollToOffset:(CGPoint)offset animated:(BOOL)animated
{
if (_layoutMetrics.layoutDirection == LayoutDirection::RightToLeft) {
// Adjusting offset.x in right to left layout direction.
offset.x = self.contentSize.width - _scrollView.frame.size.width - offset.x;
}
if (CGPointEqualToPoint(_scrollView.contentOffset, offset)) {
return;
}
[self _forceDispatchNextScrollEvent];
if (_layoutMetrics.layoutDirection == LayoutDirection::RightToLeft) {
// Adjusting offset.x in right to left layout direction.
offset.x = self.contentSize.width - _scrollView.frame.size.width - offset.x;
}
[_scrollView setContentOffset:offset animated:animated];
if (!animated) {