Skip to content

Commit 6df938c

Browse files
Regina Tukfacebook-github-bot
authored andcommitted
adding onPressMove to Pressable (#50139)
Summary: Pull Request resolved: #50139 adding this event to Pressable because it is going to be consumed after to track if pressable location is moved Changelog: [General] [Added] - Expose `onPressMove` as base prop for `Pressable` Reviewed By: thurn Differential Revision: D71429258 fbshipit-source-id: 79acaa735764a47a21d89042d3e4b9c114c72950
1 parent c2864c1 commit 6df938c

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

packages/react-native/Libraries/Components/Pressable/Pressable.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ type PressableBaseProps = $ReadOnly<{
105105
* Called when a touch is engaged before `onPress`.
106106
*/
107107
onPressIn?: ?(event: GestureResponderEvent) => mixed,
108+
/**
109+
* Called when the press location moves.
110+
*/
111+
onPressMove?: ?(event: GestureResponderEvent) => mixed,
108112

109113
/**
110114
* Called when a touch is released before `onPress`.
@@ -185,6 +189,7 @@ function Pressable(
185189
onLongPress,
186190
onPress,
187191
onPressIn,
192+
onPressMove,
188193
onPressOut,
189194
pressRetentionOffset,
190195
style,
@@ -263,7 +268,12 @@ function Pressable(
263268
onPressIn(event);
264269
}
265270
},
266-
onPressMove: android_rippleConfig?.onPressMove,
271+
onPressMove(event: GestureResponderEvent): void {
272+
android_rippleConfig?.onPressMove(event);
273+
if (onPressMove != null) {
274+
onPressMove(event);
275+
}
276+
},
267277
onPressOut(event: GestureResponderEvent): void {
268278
if (android_rippleConfig != null) {
269279
android_rippleConfig.onPressOut(event);
@@ -288,6 +298,7 @@ function Pressable(
288298
onLongPress,
289299
onPress,
290300
onPressIn,
301+
onPressMove,
291302
onPressOut,
292303
pressRetentionOffset,
293304
setPressed,

packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,6 +1719,7 @@ type PressableBaseProps = $ReadOnly<{
17191719
onLongPress?: ?(event: GestureResponderEvent) => mixed,
17201720
onPress?: ?(event: GestureResponderEvent) => mixed,
17211721
onPressIn?: ?(event: GestureResponderEvent) => mixed,
1722+
onPressMove?: ?(event: GestureResponderEvent) => mixed,
17221723
onPressOut?: ?(event: GestureResponderEvent) => mixed,
17231724
style?:
17241725
| ViewStyleProp

0 commit comments

Comments
 (0)