Repository navigation
Commit 317cc95
authored
## Summary
`GestureStateManager.activate` called from the first `onTouchesDown` was
a silent no-op on web. `onPointerDown` dispatches the touch event before
`begin()`, so the handler is still `UNDETERMINED` when the callback
runs, and `activate(true)` requires `BEGAN`.
## Test plan
<details>
<summary>Tested on the following code:</summary>
```tsx
import React from 'react';
import { StyleSheet, View } from 'react-native';
import {
GestureDetector,
GestureStateManager,
useManualGesture,
} from 'react-native-gesture-handler';
// Android + iOS. `GestureStateManager.activate` from the first `onTouchesDown`
// is a silent no-op: the native guard meant to block activation without
// touches checks the handler's state (Android `state == BEGAN`, iOS
// `_lastState != Undetermined`), and the first touch event reaches JS before
// that state is recorded, although a pointer is already tracked.
//
// Steps: press the box. Expected console: down, activated, up, deactivated.
// Bug: down, up, the gesture never activates.
export default function EmptyExample() {
const manual = useManualGesture({
onTouchesDown: (e) => {
console.log('down, state', e.state);
GestureStateManager.activate(e.handlerTag);
},
onTouchesUp: (e) => {
console.log('up, state', e.state);
GestureStateManager.deactivate(e.handlerTag);
},
onActivate: () => {
console.log('activated');
},
onDeactivate: () => {
console.log('deactivated');
},
});
return (
<View style={styles.container}>
<GestureDetector gesture={manual}>
<View style={styles.box} />
</GestureDetector>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
box: {
width: 160,
height: 160,
borderRadius: 16,
backgroundColor: '#21a37c',
},
});
```
</details>
1 parent 5be866a commit 317cc95
1 file changed
Lines changed: 12 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | | - | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
24 | 34 | | |
25 | 35 | | |
26 | 36 | | |
| |||
0 commit comments