Commit 2d6a20d
authored
## Description
This PR changes `Pinch` and `Rotation` on web so that they're not
cancelled after releasing one pointer.
## Test plan
Tested on Transformations example.
<details>
<summary>Also tested on the following code:</summary>
```tsx
import React from 'react';
import { StyleSheet, View } from 'react-native';
import {
GestureDetector,
usePinchGesture,
useRotationGesture,
useSimultaneousGestures,
} from 'react-native-gesture-handler';
import Animated, {
useAnimatedStyle,
useSharedValue,
} from 'react-native-reanimated';
export default function EmptyExample() {
const scale = useSharedValue(1);
const rotation = useSharedValue(0);
const pinch = usePinchGesture({
onBegin: () => {
console.log('[Pinch] onBegin');
},
onActivate: () => {
console.log('[Pinch] onActivate');
},
onUpdate: (e) => {
console.log('[Pinch] onUpdate scaleChange:', e.scaleChange);
scale.value *= e.scaleChange;
},
onDeactivate: () => {
console.log('[Pinch] onDeactivate');
},
onFinalize: () => {
console.log('[Pinch] onFinalize');
},
});
const rotate = useRotationGesture({
onBegin: () => {
console.log('[Rotation] onBegin');
},
onActivate: () => {
console.log('[Rotation] onActivate');
},
onUpdate: (e) => {
console.log('[Rotation] onUpdate rotationChange:', e.rotationChange);
rotation.value += e.rotationChange;
},
onDeactivate: () => {
console.log('[Rotation] onDeactivate');
},
onFinalize: () => {
console.log('[Rotation] onFinalize');
},
});
const gesture = useSimultaneousGestures(pinch, rotate);
const animatedStyle = useAnimatedStyle(() => ({
transform: [
{ scale: scale.value },
{ rotate: `${(rotation.value * 180) / Math.PI}deg` },
],
}));
return (
<View style={styles.container}>
<GestureDetector gesture={gesture}>
<Animated.View style={[styles.circle, animatedStyle]}>
<View style={styles.indicator} />
</Animated.View>
</GestureDetector>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
circle: {
width: 300,
height: 300,
borderRadius: 150,
backgroundColor: '#b58df1',
justifyContent: 'center',
alignItems: 'center',
},
indicator: {
width: 6,
height: '50%',
borderRadius: 3,
backgroundColor: 'rgba(255, 255, 255, 0.5)',
position: 'absolute',
top: 0,
},
});
```
</details>
1 parent f1f09bc commit 2d6a20d
4 files changed
Lines changed: 34 additions & 20 deletions
File tree
- packages/react-native-gesture-handler/src/web
- detectors
- handlers
Lines changed: 19 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
| 87 | + | |
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
| 92 | + | |
93 | 93 | | |
94 | | - | |
95 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
96 | 104 | | |
97 | 105 | | |
98 | 106 | | |
| |||
132 | 140 | | |
133 | 141 | | |
134 | 142 | | |
135 | | - | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
136 | 150 | | |
137 | 151 | | |
138 | 152 | | |
| |||
Lines changed: 9 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
47 | 55 | | |
48 | | - | |
49 | | - | |
50 | | - | |
| 56 | + | |
51 | 57 | | |
52 | 58 | | |
53 | 59 | | |
| |||
Lines changed: 3 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
95 | 94 | | |
| 95 | + | |
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | 116 | | |
121 | 117 | | |
122 | 118 | | |
| 119 | + | |
123 | 120 | | |
124 | 121 | | |
125 | 122 | | |
126 | | - | |
127 | 123 | | |
128 | 124 | | |
129 | 125 | | |
130 | 126 | | |
131 | 127 | | |
| 128 | + | |
132 | 129 | | |
133 | 130 | | |
134 | 131 | | |
135 | | - | |
136 | 132 | | |
137 | 133 | | |
138 | 134 | | |
| |||
Lines changed: 3 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | | - | |
104 | 103 | | |
| 104 | + | |
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| 108 | + | |
108 | 109 | | |
109 | 110 | | |
110 | 111 | | |
| |||
113 | 114 | | |
114 | 115 | | |
115 | 116 | | |
116 | | - | |
117 | | - | |
118 | 117 | | |
119 | 118 | | |
120 | 119 | | |
121 | 120 | | |
122 | 121 | | |
123 | 122 | | |
| 123 | + | |
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
133 | | - | |
134 | 132 | | |
135 | 133 | | |
136 | 134 | | |
| |||
0 commit comments