Skip to content

Commit 04c91fd

Browse files
committed
Merge branch 'next' into @mbert/add-event-calculators
2 parents a28e2c9 + 738a33c commit 04c91fd

File tree

9 files changed

+485
-208
lines changed

9 files changed

+485
-208
lines changed

apps/basic-example/metro.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const { getDefaultConfig } = require('@react-native/metro-config');
22
const { mergeConfig } = require('metro-config');
33

44
const path = require('path');
5-
const exclusionList = require('metro-config/private/defaults/exclusionList');
5+
const exclusionList = require('metro-config/private/defaults/exclusionList').default;
66
const escape = require('escape-string-regexp');
77

88
// Gesture handler tries to require 'react-native-reanimated' inside a try...catch

apps/expo-example/metro.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { getDefaultConfig } = require('expo/metro-config');
22
const path = require('path');
33

4-
const exclusionList = require('metro-config/private/defaults/exclusionList');
4+
const exclusionList = require('metro-config/private/defaults/exclusionList').default;
55
const escape = require('escape-string-regexp');
66
const pack = require('./package.json');
77

packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,13 +262,13 @@ class RNGestureHandlerButtonViewManager :
262262
}
263263
}
264264

265-
override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
266-
if (super.onInterceptTouchEvent(ev)) {
265+
override fun onInterceptTouchEvent(event: MotionEvent): Boolean {
266+
if (super.onInterceptTouchEvent(event)) {
267267
return true
268268
}
269269
// We call `onTouchEvent` and wait until button changes state to `pressed`, if it's pressed
270270
// we return true so that the gesture handler can activate.
271-
onTouchEvent(ev)
271+
onTouchEvent(event)
272272
return isPressed
273273
}
274274

packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,12 @@ class RNGestureHandlerRootHelper(private val context: ReactContext, wrappedView:
115115
}
116116
}
117117

118-
fun dispatchTouchEvent(ev: MotionEvent): Boolean {
118+
fun dispatchTouchEvent(event: MotionEvent): Boolean {
119119
// We mark `mPassingTouch` before we get into `mOrchestrator.onTouchEvent` so that we can tell
120120
// if `requestDisallow` has been called as a result of a normal gesture handling process or
121121
// as a result of one of the gesture handlers activating
122122
passingTouch = true
123-
orchestrator!!.onTouchEvent(ev)
123+
orchestrator!!.onTouchEvent(event)
124124
passingTouch = false
125125
return shouldIntercept
126126
}

packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ class RNGestureHandlerRootView(context: Context?) : ReactViewGroup(context) {
3737
rootHelper?.tearDown()
3838
}
3939

40-
override fun dispatchTouchEvent(ev: MotionEvent) = if (rootViewEnabled && rootHelper!!.dispatchTouchEvent(ev)) {
40+
override fun dispatchTouchEvent(event: MotionEvent) = if (rootViewEnabled && rootHelper!!.dispatchTouchEvent(event)) {
4141
true
4242
} else {
43-
super.dispatchTouchEvent(ev)
43+
super.dispatchTouchEvent(event)
4444
}
4545

4646
override fun dispatchGenericMotionEvent(event: MotionEvent) =

packages/react-native-gesture-handler/src/components/Pressable/Pressable.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,13 @@ const Pressable = (props: PressableProps) => {
270270
stateMachine.reset();
271271
handlePressOut(pressableEvent, false);
272272
})
273-
.onFinalize(() => {
273+
.onFinalize((_event, success) => {
274274
if (Platform.OS === 'web') {
275-
stateMachine.handleEvent(StateMachineEvent.FINALIZE);
275+
if (success) {
276+
stateMachine.handleEvent(StateMachineEvent.FINALIZE);
277+
} else {
278+
stateMachine.handleEvent(StateMachineEvent.CANCEL);
279+
}
276280
handleFinalize();
277281
}
278282
}),
@@ -301,11 +305,15 @@ const Pressable = (props: PressableProps) => {
301305
stateMachine.handleEvent(StateMachineEvent.NATIVE_START);
302306
}
303307
})
304-
.onFinalize(() => {
308+
.onFinalize((_event, success) => {
305309
if (Platform.OS !== 'web') {
306310
// On Web we use LongPress().onFinalize() instead of Native().onFinalize(),
307311
// as Native cancels on mouse move, and LongPress does not.
308-
stateMachine.handleEvent(StateMachineEvent.FINALIZE);
312+
if (success) {
313+
stateMachine.handleEvent(StateMachineEvent.FINALIZE);
314+
} else {
315+
stateMachine.handleEvent(StateMachineEvent.CANCEL);
316+
}
309317
handleFinalize();
310318
}
311319
}),

packages/react-native-gesture-handler/src/components/Pressable/stateDefinitions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export enum StateMachineEvent {
77
NATIVE_START = 'nativeStart',
88
FINALIZE = 'finalize',
99
LONG_PRESS_TOUCHES_DOWN = 'longPressTouchesDown',
10+
CANCEL = 'cancel',
1011
}
1112

1213
function getAndroidStatesConfig(

packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ import Animated, {
1111
runOnUI,
1212
useAnimatedStyle,
1313
} from 'react-native-reanimated';
14-
import { SwipeableProps, SwipeableMethods, SwipeDirection } from '.';
14+
import {
15+
SwipeableProps,
16+
SwipeableMethods,
17+
SwipeDirection,
18+
} from './ReanimatedSwipeableProps';
1519
import { Gesture } from '../..';
1620
import {
1721
GestureStateChangeEvent,

0 commit comments

Comments
 (0)