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
Called when handler stops recognizing gestures, but only if the handler activated. It is called before `onFinalize`. If the handler was interrupted, the `didSucceed` argument is set to `false`. Otherwise it is set to `true`.
61
+
Called when handler stops recognizing gestures, but only if the handler activated. It is called before `onFinalize`. The event object contains a `canceled` property — if the gesture was interrupted, `canceled`is set to `true`. Otherwise it is set to `false`.
Called when handler stops recognizing gestures. If the handler managed to activate, the `didSucceed` argument is set to `true`and `onFinalize` will be called right after `onDeactivate`. Otherwise it is set to `false`.
69
+
Called when handler stops recognizing gestures. The event object contains a `canceled` property — if the handler failed to activate or was interrupted, `canceled`is set to `true`. If the handler managed to activate and completed successfully, `canceled` is set to `false` and `onFinalize` will be called right after `onDeactivate`.
70
70
71
71
### onTouchesDown
72
72
@@ -107,14 +107,18 @@ Called when there will be no more information about this pointer. It may be call
107
107
<CollapsibleCode
108
108
label="Show composed types definitions"
109
109
expandedLabel="Hide composed types definitions"
110
-
lineBounds={[0, 4]}
110
+
lineBounds={[0, 8]}
111
111
src={`
112
112
export type GestureEvent<HandlerData> = {
113
113
handlerTag: number;
114
114
numberOfPointers: number;
115
115
pointerType: PointerType;
116
116
} & HandlerData;
117
117
118
+
export type GestureEndEvent<HandlerData> = {
119
+
canceled: boolean;
120
+
} & GestureEvent<HandlerData>;
121
+
118
122
export enum PointerType {
119
123
TOUCH,
120
124
STYLUS,
@@ -126,6 +130,10 @@ export enum PointerType {
126
130
127
131
`GestureEvent` contains properties common to all gestures (`handlerTag`, `numberOfPointers`, `pointerType`) along with gesture-specific data defined in each gesture's documentation.
128
132
133
+
### GestureEndEvent
134
+
135
+
`GestureEndEvent` extends `GestureEvent` with a `canceled` property. It is used in the [`onDeactivate`](#ondeactivate) and [`onFinalize`](#onfinalize) callbacks. When `canceled` is `true`, the gesture was interrupted or failed to activate. When `false`, the gesture completed successfully.
Set the callback that is being called when the gesture that was recognized by the handler finishes. It will be called only if the handler was previously in the active state.
31
+
Set the callback that is being called when the gesture that was recognized by the handler finishes. It will be called only if the handler was previously in the active state. The event object contains a `canceled` property — if the gesture was interrupted, `canceled` is set to `true`. Otherwise it is set to `false`.
Set the callback that is being called when the handler finalizes handling gesture - the gesture was recognized and has finished or it failed to recognize.
41
+
Set the callback that is being called when the handler finalizes handling gesture - the gesture was recognized and has finished or it failed to recognize. The event object contains a `canceled` property — if the gesture failed to activate or was interrupted, `canceled` is set to `true`. Otherwise it is set to `false`.
Copy file name to clipboardExpand all lines: packages/docs-gesture-handler/docs/guides/upgrading-to-3.mdx
+26Lines changed: 26 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -92,6 +92,32 @@ code2={
92
92
`}
93
93
/>
94
94
95
+
### canceled instead of success
96
+
97
+
In RNGH2, `onEnd` and `onFinalize` received a second `success` boolean parameter. In RNGH3, this has been replaced with a `canceled` property on the event object itself. Note that the logic is inverted — `canceled: true` corresponds to the old `success: false`.
98
+
99
+
<CodeComparison
100
+
label1={"RNGH 2"}
101
+
label2={"RNGH 3"}
102
+
code1={
103
+
`const gesture = Gesture.Tap()
104
+
.onEnd((event, success) => {
105
+
if (success) {
106
+
console.log('Gesture succeeded!');
107
+
}
108
+
});
109
+
`}
110
+
code2={
111
+
`const gesture = useTapGesture({
112
+
onDeactivate: (event) => {
113
+
if (!event.canceled) {
114
+
console.log('Gesture succeeded!');
115
+
}
116
+
},
117
+
});
118
+
`}
119
+
/>
120
+
95
121
### onChange
96
122
97
123
`onChange` callback has been removed, and its functionality has been integrated into `onUpdate`. You can now access `change*` properties in `onUpdate` callback.
Copy file name to clipboardExpand all lines: packages/docs-gesture-handler/docs/under-the-hood/state.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,6 @@ States manage the internal recognition process. You can hook into these transiti
14
14
|**`UNDETERMINED`**| The default initial state of every handler. | — |
15
15
|**`BEGAN`**| The handler has started receiving touch data but hasn't yet met the activation criteria. |[`onBegin`](/docs/fundamentals/callbacks-events#onbegin)|
16
16
|**`ACTIVE`**| The gesture is recognized and activation criteria are met. |[`onActivate`](/docs/fundamentals/callbacks-events#onactivate) when it first transitions into the `ACTIVE` state. <br /><br /> [`onUpdate`](/docs/fundamentals/callbacks-events#onupdate) when it has new data about the gesture. |
17
-
|**`END`**| The user successfully completed the gesture. |[`onDeactivate`](/docs/fundamentals/callbacks-events#ondeactivate) with `didSucceed` parameter set to `true`. <br/><br/> [`onFinalize`](/docs/fundamentals/callbacks-events#onfinalize) with `didSucceed` parameter set to `true`. |
18
-
|**`FAILED`**| The handler failed to recognize the gesture. |[`onDeactivate`](/docs/fundamentals/callbacks-events#ondeactivate) if the gesture was in `ACTIVE` state before. `didSucceed` parameter will be set to `false` <br/><br/> [`onFinalize`](/docs/fundamentals/callbacks-events#onfinalize) with `didSucceed` parameter set to `false`. |
19
-
|**`CANCELLED`**| The system interrupted the gesture. |[`onDeactivate`](/docs/fundamentals/callbacks-events#ondeactivate) if the gesture was in `ACTIVE` state before. `didSucceed` parameter will be set to `false` <br/><br/> [`onFinalize`](/docs/fundamentals/callbacks-events#onfinalize) with `didSucceed` parameter set to `false`. |
17
+
|**`END`**| The user successfully completed the gesture. |[`onDeactivate`](/docs/fundamentals/callbacks-events#ondeactivate) with `event.canceled`set to `false`. <br/><br/> [`onFinalize`](/docs/fundamentals/callbacks-events#onfinalize) with `event.canceled`set to `false`. |
18
+
|**`FAILED`**| The handler failed to recognize the gesture. |[`onDeactivate`](/docs/fundamentals/callbacks-events#ondeactivate) if the gesture was in `ACTIVE` state before, with `event.canceled`set to `true`. <br/><br/> [`onFinalize`](/docs/fundamentals/callbacks-events#onfinalize) with `event.canceled`set to `true`. |
19
+
|**`CANCELLED`**| The system interrupted the gesture. |[`onDeactivate`](/docs/fundamentals/callbacks-events#ondeactivate) if the gesture was in `ACTIVE` state before, with `event.canceled`set to `true`. <br/><br/> [`onFinalize`](/docs/fundamentals/callbacks-events#onfinalize) with `event.canceled`set to `true`. |
0 commit comments