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
This commit is contained in:
Samuel Susla
2024-03-01 04:11:40 -08:00
committed by Facebook GitHub Bot
parent d6a44e632a
commit 571ef5660a
2 changed files with 21 additions and 1 deletions
@@ -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<Props, State> {
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<Props, State> {
onTouchStart: this._handleTouchStart,
onTouchCancel: this._handleTouchCancel,
onScroll: this._handleScroll,
endDraggingSensitivityMultiplier:
experimental_endDraggingSensitivityMultiplier,
scrollEventThrottle: hasStickyHeaders
? 1
: this.props.scrollEventThrottle,
@@ -132,6 +132,7 @@ export const __INTERNAL_VIEW_CONFIG: PartialViewConfig =
},
contentInsetAdjustmentBehavior: true,
decelerationRate: true,
endDraggingSensitivityMultiplier: true,
directionalLockEnabled: true,
disableIntervalMomentum: true,
indicatorStyle: true,