Commit 15478f6
authored
## Description
Currently we have 2 ways of handling events - `Animated` and `JS`/`Reanimated`. Handling both `JS` and `Reanimated` in the same places results in more complex codebase. It also introduces problems with composing gestures. We decided to split those implementations.
## Test plan
<details>
<summary>Tested on the following code:</summary>
```tsx
import * as React from 'react';
import { Animated, Button, useAnimatedValue } from 'react-native';
import {
GestureHandlerRootView,
NativeDetector,
useGesture,
} from 'react-native-gesture-handler';
export default function App() {
const [visible, setVisible] = React.useState(true);
const value = useAnimatedValue(0);
const event = Animated.event(
[{ nativeEvent: { handlerData: { translationX: value } } }],
{
useNativeDriver: true,
}
);
const gesture = useGesture('PanGestureHandler', {
onBegin: (e: unknown) => {
'worklet';
console.log('onBegin', e);
},
onStart: (e: unknown) => {
'worklet';
console.log('onStart', e);
},
// onUpdate: event,
onUpdate: (e: unknown) => {
'worklet';
console.log('onUpdate', e);
},
onEnd: (e: unknown) => {
'worklet';
console.log('onEnd', e);
},
onFinalize: (e: unknown) => {
'worklet';
console.log('onFinalize', e);
},
onTouchesDown: (e: unknown) => {
'worklet';
console.log('onTouchesDown', e);
},
onTouchesMove: (e: unknown) => {
'worklet';
console.log('onTouchesMoved', e);
},
onTouchesUp: (e: unknown) => {
'worklet';
console.log('onTouchesUp', e);
},
onTouchesCancelled: (e: unknown) => {
'worklet';
console.log('onTouchesCancelled', e);
},
});
return (
<GestureHandlerRootView
style={{ flex: 1, backgroundColor: 'white', paddingTop: 8 }}>
<Button
title="Toggle visibility"
onPress={() => {
setVisible(!visible);
}}
/>
{visible && (
<NativeDetector gesture={gesture}>
<Animated.View
style={[
{
width: 150,
height: 150,
backgroundColor: 'blue',
opacity: 0.5,
borderWidth: 10,
borderColor: 'green',
marginTop: 20,
marginLeft: 40,
},
{ transform: [{ translateX: value }] },
]}
/>
</NativeDetector>
)}
</GestureHandlerRootView>
);
}
```
</details>
1 parent 67f6be0 commit 15478f6
File tree
58 files changed
+763
-414
lines changed- packages/react-native-gesture-handler
- android/src/main/java/com/swmansion/gesturehandler
- core
- react
- events
- eventbuilders
- apple
- src
- handlers/gestures
- specs
- v3
- hooks
- callbacks
- js
- reanimated
- events
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
58 files changed
+763
-414
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
Lines changed: 11 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
| 22 | + | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| 83 | + | |
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
| |||
131 | 132 | | |
132 | 133 | | |
133 | 134 | | |
| 135 | + | |
| 136 | + | |
134 | 137 | | |
135 | 138 | | |
136 | 139 | | |
| |||
886 | 889 | | |
887 | 890 | | |
888 | 891 | | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
889 | 895 | | |
890 | 896 | | |
891 | 897 | | |
| |||
901 | 907 | | |
902 | 908 | | |
903 | 909 | | |
| 910 | + | |
904 | 911 | | |
905 | 912 | | |
906 | 913 | | |
| |||
973 | 980 | | |
974 | 981 | | |
975 | 982 | | |
| 983 | + | |
| 984 | + | |
976 | 985 | | |
977 | 986 | | |
978 | 987 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
0 commit comments