You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/docs-gesture-handler/docs/guides/upgrading-to-3.mdx
+74-64Lines changed: 74 additions & 64 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,26 +5,30 @@ title: Upgrading to the new API introduced in Gesture Handler 3
5
5
6
6
## Migrating gestures
7
7
8
-
The most important change brought by the Gesture Handler 3 is the new hook API. Migration is pretty straight-forward. Instead of calling builder methods, everything is passed into configuration object. So, the code like this:
The most important change brought by the Gesture Handler 3 is the new hook API. Migration is pretty straight-forward. Instead of calling builder methods, everything is passed into configuration object.
12
+
13
+
<CodeComparison
14
+
label1={"RNGH 2"}
15
+
label2={"RNGH 3"}
16
+
code1={
17
+
`const gesture = Gesture.Pan()
12
18
.onBegin(() => {
13
19
console.log('Pan!');
14
20
})
15
21
.minDistance(25);
16
-
```
17
-
18
-
Now looks like this:
19
-
20
-
```tsx
21
-
const gesture =usePanGesture({
22
-
onBegin: () => {
23
-
console.log('Pan!');
24
-
},
25
-
minDistance: 25,
26
-
});
27
-
```
22
+
`}
23
+
code2={
24
+
`const gesture = usePanGesture({
25
+
onBegin: () => {
26
+
console.log('Pan!');
27
+
},
28
+
minDistance: 25,
29
+
});
30
+
`}
31
+
/>
28
32
29
33
:::danger Force Touch Gesture
30
34
[`ForceTouch`](/docs/2.x/gestures/force-touch-gesture) gesture is not available in hook API.
Previously, composed gestures were created using `Gesture` object. In Gesture Handler 3, relations are set up using relation hooks. For example, the following code from Gesture Handler 2:
96
+
Previously, composed gestures were created using `Gesture` object. In Gesture Handler 3, relations are set up using relation hooks.
In Gesture Handler 2 it was possible to use `GestureDetector` directly on `SVG`:
157
+
In Gesture Handler 2 it was possible to use `GestureDetector` directly on `SVG`. In Gesture Handler 3, the correct way to interact with `SVG` is to use `InterceptingGestureDetector` and `VirtualGestureDetector`.
147
158
148
-
```tsx
149
-
// highlight-next-line
159
+
<CodeComparison
160
+
label1={"RNGH 2"}
161
+
label2={"RNGH 3"}
162
+
code1={
163
+
`
150
164
<GestureDetector gesture={containerTap}>
151
165
<Svg>
152
-
// highlight-next-line
153
-
<GestureDetectorgesture={circleElementTap}>
166
+
<GestureDetector gesture={circleTap}>
154
167
<Circle />
155
168
</GestureDetector>
156
169
</Svg>
157
170
</GestureDetector>
158
-
```
159
-
160
-
In Gesture Handler 3, the correct way to interact with `SVG` is to use `InterceptingGestureDetector` and `VirtualGestureDetector`:
0 commit comments