Skip to content

Commit a1b49ec

Browse files
committed
fix: prevent programmatic scrolls from cancelling active touches on iOS
1 parent 102fde7 commit a1b49ec

3 files changed

Lines changed: 5 additions & 1 deletion

File tree

packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,7 @@ - (BOOL)_shouldDisableScrollInteraction
599599
metrics.containerSize = RCTSizeFromCGSize(_scrollView.bounds.size);
600600
metrics.zoomScale = _scrollView.zoomScale;
601601
metrics.timestamp = CACurrentMediaTime();
602+
metrics.responderIgnoreScroll = !_isUserTriggeredScrolling;
602603

603604
if (_layoutMetrics.layoutDirection == LayoutDirection::RightToLeft) {
604605
metrics.contentOffset.x = metrics.contentSize.width - metrics.containerSize.width - metrics.contentOffset.x;

packages/react-native/ReactCommon/react/renderer/components/scrollview/ScrollEvent.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ jsi::Value ScrollEvent::asJSIValue(jsi::Runtime& runtime) const {
4444

4545
payload.setProperty(runtime, "zoomScale", zoomScale);
4646
payload.setProperty(runtime, "timestamp", timestamp * 1000);
47+
payload.setProperty(runtime, "responderIgnoreScroll", responderIgnoreScroll);
4748

4849
return payload;
4950
}
@@ -67,7 +68,8 @@ folly::dynamic ScrollEvent::asDynamic() const {
6768
"contentInset", std::move(contentInsetObj))(
6869
"contentSize", std::move(contentSizeObj))(
6970
"layoutMeasurement", std::move(containerSizeObj))(
70-
"zoomScale", zoomScale)("timestamp", timestamp * 1000);
71+
"zoomScale", zoomScale)("timestamp", timestamp * 1000)(
72+
"responderIgnoreScroll", responderIgnoreScroll);
7173

7274
return metrics;
7375
};

packages/react-native/ReactCommon/react/renderer/components/scrollview/ScrollEvent.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ struct ScrollEvent : public EventPayload {
2121
EdgeInsets contentInset;
2222
Size containerSize;
2323
Float zoomScale{};
24+
bool responderIgnoreScroll{false};
2425

2526
/*
2627
* The time in seconds when the touch occurred or when it was last mutated.

0 commit comments

Comments
 (0)