From dfbf7d4e142a35c5380019a3b485cbad0922e063 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Mon, 8 Aug 2022 05:01:19 -0700 Subject: [PATCH] Early exit in scrollToOffset if contentOffset wouldn't change Summary: changelog: [internal] Calling `scrollToOffset` with already set content offset doesn't make sense. Reviewed By: cipolleschi Differential Revision: D38499666 fbshipit-source-id: ee0bb155fa1619dfd49bca434bf2eee7ad7df9e0 --- .../ComponentViews/ScrollView/RCTScrollViewComponentView.mm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm index 9101970c8a0..2ebbb0e82ac 100644 --- a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm @@ -649,6 +649,10 @@ static void RCTSendScrollEventForNativeAnimations_DEPRECATED(UIScrollView *scrol - (void)scrollToOffset:(CGPoint)offset animated:(BOOL)animated { + if (CGPointEqualToPoint(_scrollView.contentOffset, offset)) { + return; + } + [self _forceDispatchNextScrollEvent]; if (_layoutMetrics.layoutDirection == LayoutDirection::RightToLeft) {