Skip to content

Commit

Permalink
Fix bad comparison in RCTScrollViewComponentView RTL (#39030)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #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
  • Loading branch information
NickGerleman authored and facebook-github-bot committed Aug 16, 2023
1 parent 676676c commit 65b7680
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -675,17 +675,17 @@ - (void)scrollToOffset:(CGPoint)offset

- (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) {
Expand Down

0 comments on commit 65b7680

Please sign in to comment.