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
This commit is contained in:
Nick Gerleman
2023-09-05 09:02:19 -07:00
committed by Facebook GitHub Bot
parent c8d72156bc
commit a410ef97f6
@@ -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<const ScrollViewEventEmitter &>(*_eventEmitter).onScroll([self _scrollViewMetrics]);