From 571ef5660abb82d6ed842b6d5d8a9daf152177f0 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Fri, 1 Mar 2024 04:11:40 -0800 Subject: [PATCH] introduce experimental props to ScrollView - JS part (#43265) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/43265 changelog: [internal] Add experimental props to control scroll speed on iOS. Reviewed By: rubennorte Differential Revision: D53757138 fbshipit-source-id: e4d9787240ad421d3e4a1d50c860d7bcb26f43b5 --- .../Components/ScrollView/ScrollView.js | 21 ++++++++++++++++++- .../ScrollView/ScrollViewNativeComponent.js | 1 + 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/react-native/Libraries/Components/ScrollView/ScrollView.js b/packages/react-native/Libraries/Components/ScrollView/ScrollView.js index aab9f20baf2..d8814ccefc4 100644 --- a/packages/react-native/Libraries/Components/ScrollView/ScrollView.js +++ b/packages/react-native/Libraries/Components/ScrollView/ScrollView.js @@ -438,6 +438,20 @@ export type Props = $ReadOnly<{| * - `'fast'`: 0.99 on iOS, 0.9 on Android */ decelerationRate?: ?DecelerationRateType, + + /** + * *Experimental, iOS Only*. The API is experimental and will change in future releases. + * + * Controls how much distance is travelled after user stops scrolling. + * Value greater than 1 will increase the distance travelled. + * Value less than 1 will decrease the distance travelled. + * + * @deprecated + * + * The default value is 1. + */ + experimental_endDraggingSensitivityMultiplier?: ?number, + /** * When true, the scroll view's children are arranged horizontally in a row * instead of vertically in a column. The default value is false. @@ -1733,8 +1747,11 @@ class ScrollView extends React.Component { this.props.horizontal === true ? styles.baseHorizontal : styles.baseVertical; + + const {experimental_endDraggingSensitivityMultiplier, ...otherProps} = + this.props; const props = { - ...this.props, + ...otherProps, alwaysBounceHorizontal, alwaysBounceVertical, style: StyleSheet.compose(baseStyle, this.props.style), @@ -1759,6 +1776,8 @@ class ScrollView extends React.Component { onTouchStart: this._handleTouchStart, onTouchCancel: this._handleTouchCancel, onScroll: this._handleScroll, + endDraggingSensitivityMultiplier: + experimental_endDraggingSensitivityMultiplier, scrollEventThrottle: hasStickyHeaders ? 1 : this.props.scrollEventThrottle, diff --git a/packages/react-native/Libraries/Components/ScrollView/ScrollViewNativeComponent.js b/packages/react-native/Libraries/Components/ScrollView/ScrollViewNativeComponent.js index 7c250c9a30b..8c112684902 100644 --- a/packages/react-native/Libraries/Components/ScrollView/ScrollViewNativeComponent.js +++ b/packages/react-native/Libraries/Components/ScrollView/ScrollViewNativeComponent.js @@ -132,6 +132,7 @@ export const __INTERNAL_VIEW_CONFIG: PartialViewConfig = }, contentInsetAdjustmentBehavior: true, decelerationRate: true, + endDraggingSensitivityMultiplier: true, directionalLockEnabled: true, disableIntervalMomentum: true, indicatorStyle: true,