From e173bbe3bb2e339bfdaa15168d87898b20ec12a5 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Tue, 18 May 2021 10:01:04 -0700 Subject: [PATCH] Fix on demand mounting in RTL Summary: Changelog: [internal] When calculating on demand views, RTL layout needs to be considered. Reviewed By: JoshuaGross Differential Revision: D28510293 fbshipit-source-id: 5e7b08fcc5c55fa1a978024a9bfedda705ce1702 --- .../ComponentViews/ScrollView/RCTScrollViewComponentView.mm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm index 48816f4c3cf..9ba3054513b 100644 --- a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm @@ -622,10 +622,11 @@ static void RCTSendPaperScrollEvent_DEPRECATED(UIScrollView *scrollView, NSInteg return; } - CGRect visibleFrame = CGRect{_scrollView.contentOffset, _scrollView.bounds.size}; + CGRect visibleFrame = [_scrollView convertRect:_scrollView.bounds toView:_containerView]; visibleFrame = CGRectInset(visibleFrame, -kClippingLeeway, -kClippingLeeway); - CGFloat scale = 1.0 / _scrollView.zoomScale; + // `zoomScale` is negative in RTL. Absolute value is needed. + CGFloat scale = 1.0 / std::abs(_scrollView.zoomScale); visibleFrame.origin.x *= scale; visibleFrame.origin.y *= scale; visibleFrame.size.width *= scale;