Skip to content

Commit f580090

Browse files
authored
[Docs] Add callbacks flow charts (#4354)
## Description This PR adds interactive chart flows for gesture callbacks. They replace old graphs. ## Gesture callbacks ### Before https://github.com/user-attachments/assets/ff8769af-a998-401f-86dc-a5cf1bda21e5 ### After https://github.com/user-attachments/assets/fe47deba-9619-4699-bba8-59d64e67d6ce ## TouchEvent callbacks ### Before https://github.com/user-attachments/assets/8e6dbf6c-fb25-411e-b995-5e361bdacf65 ### After https://github.com/user-attachments/assets/fa6d66aa-bdcb-4838-9e18-76c75f3df229 ## Test plan Read docs 🤓
1 parent 3b997dc commit f580090

12 files changed

Lines changed: 950 additions & 226 deletions

File tree

packages/docs-gesture-handler/docs/fundamentals/callbacks-events.mdx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ sidebar_label: Gesture callbacks & events
55
sidebar_position: 5
66
---
77

8-
import { GestureEventFlowChart, TouchEventFlowChart } from '@site/src/examples/CallbacksFlowCharts'
8+
import {
9+
GestureCallbacksExample,
10+
TouchCallbacksExample,
11+
} from '@site/src/examples/CallbacksFlowExamples';
912

1013
At any given time, each handler instance has an assigned [state](/docs/under-the-hood/state) that can change when new touch events occur or can be forced to change by the touch system under certain circumstances. You can hook into state transitions using specific [gesture callbacks](#callbacks).
1114

@@ -15,7 +18,9 @@ When Reanimated is installed, all callbacks are automatically workletized. For m
1518

1619
### GestureEvent callbacks
1720

18-
<GestureEventFlowChart />
21+
Drag or hold the circle below to see how the callback chain reacts.
22+
23+
<GestureCallbacksExample />
1924

2025
Note that some of these callbacks are complementary:
2126

@@ -24,7 +29,9 @@ Note that some of these callbacks are complementary:
2429

2530
### TouchEvent callbacks
2631

27-
<TouchEventFlowChart />
32+
Low-level `TouchEvent` callbacks are tied to raw pointer activity. Drag out of the card to cancel, or release inside it to see how the callback chain reacts.
33+
34+
<TouchCallbacksExample />
2835

2936
## Callbacks
3037

@@ -41,7 +48,7 @@ Called when a handler begins to recognize gestures. If `onBegin` was called, it
4148
```ts
4249
onActivate: (event: GestureEvent<HandlerData>) => void
4350
```
44-
51+
4552
Called when activation criteria for the handler are met. If `onActivate` was called, it is guaranteed that `onDeactivate` will be called later.
4653

4754
### onUpdate
@@ -185,7 +192,7 @@ export type TouchData = {
185192
};
186193
`}/>
187194

188-
`TouchEvent` carries information about raw touch events, like touching the screen or moving the finger.
195+
`TouchEvent` carries information about raw touch events, like touching the screen or moving the finger.
189196

190197
- `eventType` - Type of the current event - whether the finger was placed on the screen, moved, lifted or cancelled.
191198

@@ -195,7 +202,7 @@ export type TouchData = {
195202

196203
- `numberOfTouches` - Number representing the count of currently active touches.
197204

198-
`TouchData` contains information about a single touch.
205+
`TouchData` contains information about a single touch.
199206

200207
- `id` - A number representing the id of the touch. It may be used to track the touch between events as the id will not change while it is being tracked.
201208

@@ -210,4 +217,3 @@ export type TouchData = {
210217
:::danger
211218
Don't rely on the order of items in the `changedTouches`/`allTouches` arrays as it may change during the gesture, instead use the `id` attribute to track individual touches across events.
212219
:::
213-

packages/docs-gesture-handler/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@
5454
"react-native-worklets": "0.8.1",
5555
"source-map": "^0.7.4",
5656
"source-map-loader": "^4.0.1",
57-
"usehooks-ts": "^2.9.1",
58-
"vis-network": "^10.0.2"
57+
"usehooks-ts": "^2.9.1"
5958
},
6059
"devDependencies": {
6160
"@docusaurus/module-type-aliases": "3.9.2",

packages/docs-gesture-handler/src/examples/CallbacksFlowCharts/FlowChart.jsx

Lines changed: 0 additions & 126 deletions
This file was deleted.

packages/docs-gesture-handler/src/examples/CallbacksFlowCharts/GestureEventChart.jsx

Lines changed: 0 additions & 45 deletions
This file was deleted.

packages/docs-gesture-handler/src/examples/CallbacksFlowCharts/TouchEventChart.jsx

Lines changed: 0 additions & 39 deletions
This file was deleted.

packages/docs-gesture-handler/src/examples/CallbacksFlowCharts/index.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)