Commit 5d60a09
authored
## Description
I've noticed that `Pinch` and `Rotation` behave weirdly when it comes to
ending gesture on web. I've took a look and fixed some minor issues.
> [!NOTE]
> This PR may introduce mismatch between `android` and `web` versions of
`Rotation`. I still think that this is how it is supposed to work, so we
may want to [make required changes to `android` as
well](#4079)
(or drop this PR if you prefer to).
### Pinch
I've noticed that `Pinch` is not reset when pointers are placed on view
and then released. This was because for some reason `Pinch` simply
ignored finished states if it had not activated earlier.
### Rotation
`Rotation`, always finalized with `true`. This was because we always
tried to move it to `end` state. Our internal event handler hadn't been
sending `onDeactivate`, but `true` was still passed into `onFinalize`.
## Test plan
<details>
<summary>Tested on Transformations example and code below:</summary>
```tsx
import { StyleSheet, View } from 'react-native';
import {
GestureDetector,
GestureHandlerRootView,
usePinchGesture,
useRotationGesture,
} from 'react-native-gesture-handler';
export default function App() {
const g = useRotationGesture({
onBegin: () => console.log('onBegin'),
onActivate: () => console.log('onActivate'),
onUpdate: (e) => console.log('onUpdate', e.rotation),
onDeactivate: () => console.log('onDeactivate'),
onFinalize: (_, s) => console.log('onFinalize', s),
});
return (
<GestureHandlerRootView style={styles.container}>
<GestureDetector gesture={g}>
<View style={styles.box} />
</GestureDetector>
</GestureHandlerRootView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
box: {
width: 200,
height: 200,
backgroundColor: 'blue',
borderRadius: 12,
},
});
```
</details>
1 parent b09afc0 commit 5d60a09
3 files changed
Lines changed: 13 additions & 22 deletions
File tree
- packages/react-native-gesture-handler/src/web
- detectors
- handlers
Lines changed: 5 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
79 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
80 | 81 | | |
81 | 82 | | |
82 | | - | |
83 | | - | |
84 | 83 | | |
85 | 84 | | |
86 | 85 | | |
| |||
138 | 137 | | |
139 | 138 | | |
140 | 139 | | |
141 | | - | |
142 | | - | |
143 | | - | |
| 140 | + | |
| 141 | + | |
144 | 142 | | |
145 | 143 | | |
146 | 144 | | |
| |||
Lines changed: 3 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | 101 | | |
106 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
107 | 106 | | |
108 | 107 | | |
109 | 108 | | |
| |||
Lines changed: 5 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
45 | 49 | | |
46 | 50 | | |
47 | 51 | | |
| |||
136 | 140 | | |
137 | 141 | | |
138 | 142 | | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | 143 | | |
150 | 144 | | |
151 | 145 | | |
| |||
0 commit comments