diff --git a/React/Base/RCTConstants.h b/React/Base/RCTConstants.h index c6e287605d4..80dfd9675f0 100644 --- a/React/Base/RCTConstants.h +++ b/React/Base/RCTConstants.h @@ -17,6 +17,12 @@ RCT_EXTERN NSString *const RCTUserInterfaceStyleDidChangeNotificationTraitCollec RCT_EXTERN BOOL RCTExperimentGetOnDemandViewMounting(void); RCT_EXTERN void RCTExperimentSetOnDemandViewMounting(BOOL value); +/* + * Allows sending scroll events to Paper. + */ +RCT_EXTERN BOOL RCTExperimentGetSendScrollEventToPaper(void); +RCT_EXTERN void RCTExperimentSetSendScrollEventToPaper(BOOL value); + /* * Preemptive View Allocation */ diff --git a/React/Base/RCTConstants.m b/React/Base/RCTConstants.m index ecd001c493d..16d8e5913ee 100644 --- a/React/Base/RCTConstants.m +++ b/React/Base/RCTConstants.m @@ -25,6 +25,21 @@ void RCTExperimentSetOnDemandViewMounting(BOOL value) RCTExperimentOnDemandViewMounting = value; } +/* + * Send scroll events to Paper. + */ +static BOOL RCTExperimentSendScrollEventToPaper = YES; + +BOOL RCTExperimentGetSendScrollEventToPaper() +{ + return RCTExperimentSendScrollEventToPaper; +} + +void RCTExperimentSetSendScrollEventToPaper(BOOL value) +{ + RCTExperimentSendScrollEventToPaper = value; +} + /* * Preemptive View Allocation */ diff --git a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm index 9ba3054513b..4cd8858df34 100644 --- a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm @@ -87,6 +87,7 @@ static void RCTSendPaperScrollEvent_DEPRECATED(UIScrollView *scrollView, NSInteg BOOL _isUserTriggeredScrolling; BOOL _isOnDemandViewMountingEnabled; + BOOL _sendScrollEventToPaper; CGPoint _contentOffsetWhenClipped; NSMutableArray *> *_childComponentViews; } @@ -106,6 +107,7 @@ static void RCTSendPaperScrollEvent_DEPRECATED(UIScrollView *scrollView, NSInteg _props = defaultProps; _isOnDemandViewMountingEnabled = RCTExperimentGetOnDemandViewMounting(); + _sendScrollEventToPaper = RCTExperimentGetSendScrollEventToPaper(); _childComponentViews = [[NSMutableArray alloc] init]; _scrollView = [[RCTEnhancedScrollView alloc] initWithFrame:self.bounds]; @@ -419,7 +421,9 @@ static void RCTSendPaperScrollEvent_DEPRECATED(UIScrollView *scrollView, NSInteg } // Once Fabric implements proper NativeAnimationDriver, this should be removed. // This is just a workaround to allow animations based on onScroll event. - RCTSendPaperScrollEvent_DEPRECATED(scrollView, self.tag); + if (_sendScrollEventToPaper) { + RCTSendPaperScrollEvent_DEPRECATED(scrollView, self.tag); + } } [self _remountChildrenIfNeeded]; diff --git a/React/Fabric/RCTSurfacePresenter.mm b/React/Fabric/RCTSurfacePresenter.mm index 43b154efdb6..212a8463c02 100644 --- a/React/Fabric/RCTSurfacePresenter.mm +++ b/React/Fabric/RCTSurfacePresenter.mm @@ -257,6 +257,10 @@ static BackgroundExecutor RCTGetBackgroundExecutor() RCTExperimentSetOnDemandViewMounting(YES); } + if (reactNativeConfig && reactNativeConfig->getBool("react_fabric:disable_sending_scroll_events_to_paper")) { + RCTExperimentSetSendScrollEventToPaper(NO); + } + if (reactNativeConfig && reactNativeConfig->getBool("react_fabric:preemptive_view_allocation_disabled_ios")) { RCTExperimentSetPreemptiveViewAllocationDisabled(YES); }