From a410ef97f6bb735da2946cc9ac7712c821e3bc41 Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Tue, 5 Sep 2023 09:02:19 -0700 Subject: [PATCH] Only disable throttling when scrollEventThrottle isn't set (#39293) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/39293 This QE is meant to change behavior to not throttle if `scrollEventThrottle` isn't set, but it's actually disabling throttling entirely. This changes the gating to instead change the initialization path to set `_scrollEventThrottle = 0` when the QE is set. `_scrollEventThrottle` is already set to zero when the `scrollEventThrottle` prop is removed/set to null, as the default value in ScrollViewProps. Changelog: [internal] Reviewed By: sammy-SC Differential Revision: D48968754 fbshipit-source-id: c46c7f5093a60e326267c2e5f2f86dc2d545ac7f --- .../ScrollView/RCTScrollViewComponentView.mm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm index 1896eb96e07..504b0ef147a 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm @@ -134,7 +134,11 @@ static void RCTSendScrollEventForNativeAnimations_DEPRECATED(UIScrollView *scrol [self.scrollViewDelegateSplitter addDelegate:self]; - _scrollEventThrottle = INFINITY; + if (CoreFeatures::disableScrollEventThrottleRequirement) { + _scrollEventThrottle = 0; + } else { + _scrollEventThrottle = INFINITY; + } } return self; @@ -447,8 +451,7 @@ static void RCTSendScrollEventForNativeAnimations_DEPRECATED(UIScrollView *scrol } NSTimeInterval now = CACurrentMediaTime(); - if (CoreFeatures::disableScrollEventThrottleRequirement || (_lastScrollEventDispatchTime == 0) || - (now - _lastScrollEventDispatchTime > _scrollEventThrottle)) { + if ((_lastScrollEventDispatchTime == 0) || (now - _lastScrollEventDispatchTime > _scrollEventThrottle)) { _lastScrollEventDispatchTime = now; if (_eventEmitter) { static_cast(*_eventEmitter).onScroll([self _scrollViewMetrics]);