@@ -563,31 +563,29 @@ - (void)flashScrollIndicators
563
563
- (void )scrollTo : (double )x y : (double )y animated : (BOOL )animated
564
564
{
565
565
CGPoint offset = CGPointMake (x, y);
566
- if (!CGPointEqualToPoint (_scrollView.contentOffset , offset)) {
567
- CGRect maxRect = CGRectMake (
568
- fmin (-_scrollView.contentInset .left , 0 ),
569
- fmin (-_scrollView.contentInset .top , 0 ),
570
- fmax (
571
- _scrollView.contentSize .width - _scrollView.bounds .size .width + _scrollView.contentInset .right +
572
- fmax (_scrollView.contentInset .left , 0 ),
573
- 0.01 ),
574
- fmax (
575
- _scrollView.contentSize .height - _scrollView.bounds .size .height + _scrollView.contentInset .bottom +
576
- fmax (_scrollView.contentInset .top , 0 ),
577
- 0.01 )); // Make width and height greater than 0
578
-
579
- const auto &props = *std::static_pointer_cast<const ScrollViewProps>(_props);
580
- if (!CGRectContainsPoint (maxRect, offset) && !props.scrollToOverflowEnabled ) {
581
- CGFloat localX = fmax (offset.x , CGRectGetMinX (maxRect));
582
- localX = fmin (localX, CGRectGetMaxX (maxRect));
583
- CGFloat localY = fmax (offset.y , CGRectGetMinY (maxRect));
584
- localY = fmin (localY, CGRectGetMaxY (maxRect));
585
- offset = CGPointMake (localX, localY);
586
- }
566
+ CGRect maxRect = CGRectMake (
567
+ fmin (-_scrollView.contentInset .left , 0 ),
568
+ fmin (-_scrollView.contentInset .top , 0 ),
569
+ fmax (
570
+ _scrollView.contentSize .width - _scrollView.bounds .size .width + _scrollView.contentInset .right +
571
+ fmax (_scrollView.contentInset .left , 0 ),
572
+ 0.01 ),
573
+ fmax (
574
+ _scrollView.contentSize .height - _scrollView.bounds .size .height + _scrollView.contentInset .bottom +
575
+ fmax (_scrollView.contentInset .top , 0 ),
576
+ 0.01 )); // Make width and height greater than 0
587
577
588
- [self _forceDispatchNextScrollEvent ];
589
- [_scrollView setContentOffset: offset animated: animated];
578
+ const auto &props = *std::static_pointer_cast<const ScrollViewProps>(_props);
579
+ if (!CGRectContainsPoint (maxRect, offset) && !props.scrollToOverflowEnabled ) {
580
+ CGFloat localX = fmax (offset.x , CGRectGetMinX (maxRect));
581
+ localX = fmin (localX, CGRectGetMaxX (maxRect));
582
+ CGFloat localY = fmax (offset.y , CGRectGetMinY (maxRect));
583
+ localY = fmin (localY, CGRectGetMaxY (maxRect));
584
+ offset = CGPointMake (localX, localY);
590
585
}
586
+
587
+ [self _forceDispatchNextScrollEvent ];
588
+ [self scrollToOffset: offset animated: animated];
591
589
}
592
590
593
591
- (void )scrollToEnd : (BOOL )animated
@@ -602,7 +600,7 @@ - (void)scrollToEnd:(BOOL)animated
602
600
offset = CGPointMake (0 , fmax (offsetY, 0 ));
603
601
}
604
602
605
- [_scrollView setContentOffset : offset animated: animated];
603
+ [self scrollToOffset : offset animated: animated];
606
604
}
607
605
608
606
#pragma mark - Child views mounting
@@ -707,7 +705,13 @@ - (void)scrollToOffset:(CGPoint)offset
707
705
- (void )scrollToOffset : (CGPoint)offset animated : (BOOL )animated
708
706
{
709
707
[self _forceDispatchNextScrollEvent ];
710
- [self .scrollView setContentOffset: offset animated: animated];
708
+
709
+ if (_layoutMetrics.layoutDirection == LayoutDirection::RightToLeft) {
710
+ // Adjusting offset.x in right to left layout direction.
711
+ offset.x = self.contentSize .width - _scrollView.frame .size .width - offset.x ;
712
+ }
713
+
714
+ [_scrollView setContentOffset: offset animated: animated];
711
715
}
712
716
713
717
- (void )zoomToRect : (CGRect)rect animated : (BOOL )animated
0 commit comments