Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/docs-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ jobs:
uses: actions/setup-node@v6
with:
node-version: 24
cache: yarn

- name: Install node dependencies
working-directory: ${{ env.WORKING_DIRECTORY }}
Expand Down
2 changes: 1 addition & 1 deletion packages/docs-gesture-handler/docs/components/buttons.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Currently Gesture handler library exposes three components that render native to
- [`RectButton`](/docs/components/buttons/#rectbutton)
- [`BorderlessButton`](/docs/components/buttons/#borderlessbutton)

On top of that all the buttons are wrapped with `NativeViewGestureHandler` and therefore allow for all the [common gesture handler properties](/docs/gesture-handlers/common-gh/) and `NativeViewGestureHandler`'s [extra properties](/docs/gesture-handlers/nativeview-gh#properties) to be applied to them.
On top of that all the buttons are wrapped with `NativeViewGestureHandler` and therefore allow for all the [common gesture handler properties](/docs/gestures/use-native-gesture#properties-common-to-all-gestures) and `NativeViewGestureHandler`'s [extra properties](/docs/gestures/use-native-gesture#properties-specific-to-nativegesture) to be applied to them.

**IMPORTANT**: In order to make buttons accessible, you have to wrap your children in a `View` with `accessible` and `accessibilityRole="button"` props.
Example:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import CodeBlock from '@theme/CodeBlock';

### Callbacks common to all continuous gestures:

### onUpdate

{
<CodeBlock className="language-ts">
{`onUpdate: (event: ${props.gesture}HandlerData) => void`}
</CodeBlock>
}

Set the callback that is being called every time the gesture receives an update while it's active.
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
### Properties common to all continuous gestures:

### `manualActivation(value: boolean)`
### manualActivation

```ts
manualActivation: boolean | SharedValue<boolean>;
```

When `true` the handler will not activate by itself even if its activation criteria are met. Instead you can manipulate its state using [state manager](/docs/gestures/state-manager/).
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import CodeBlock from '@theme/CodeBlock';

### Callbacks common to all gestures:

### onBegin

{
<CodeBlock className="language-ts">
{`onBegin: (event: ${props.gesture}HandlerData) => void`}
</CodeBlock>
}

Set the callback that is being called when given gesture handler starts receiving touches. At the moment of this callback the handler is not yet in an active state and we don't know yet if it will recognize the gesture at all.

### onActivate

{
<CodeBlock className="language-ts">
{`onActivate: (event: ${props.gesture}HandlerData) => void`}
</CodeBlock>
}

Set the callback that is being called when the gesture is recognized by the handler and it transitions to the active state.

### onDeactivate

{
<CodeBlock className="language-ts">
{`onDeactivate: (event: ${props.gesture}HandlerData, didSucceed: boolean) => void`}
</CodeBlock>
}

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.

### onFinalize

{
<CodeBlock className="language-ts">
{`onFinalize: (event: ${props.gesture}HandlerData, didSucceed: boolean) => void`}
</CodeBlock>
}

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.

### onTouchesDown

```ts
onTouchesDown: (event: GestureTouchEvent) => void
```

Set the `onTouchesDown` callback which is called every time a finger is placed on the screen.

### onTouchesMove

```ts
onTouchesMove: (event: GestureTouchEvent) => void
```

Set the `onTouchesMove` callback which is called every time a finger is moved on the screen.

### onTouchesUp

```ts
onTouchesUp: (event: GestureTouchEvent) => void
```

Set the `onTouchesUp` callback which is called every time a finger is lifted from the screen.

### onTouchesCancel

```ts
onTouchesCancel: (event: GestureTouchEvent) => void
```

Set the `onTouchesCancel` callback which is called every time a finger stops being tracked, for example when the gesture finishes.
Original file line number Diff line number Diff line change
@@ -1,19 +1,48 @@
### Properties common to all gestures:

### `enabled(value: boolean)`
### enabled

```ts
enabled: boolean | SharedValue<boolean>;
```

Indicates whether the given handler should be analyzing stream of touch events or not.
When set to `false` we can be sure that the handler's state will **never** become [`ACTIVE`](/docs/fundamentals/states-events#active).
If the value gets updated while the handler already started recognizing a gesture, then the handler's state it will immediately change to [`FAILED`](/docs/fundamentals/states-events#failed) or [`CANCELLED`](/docs/fundamentals/states-events#cancelled) (depending on its current state).
Default value is `true`.

### `shouldCancelWhenOutside(value: boolean)`
### shouldCancelWhenOutside

```ts
shouldCancelWhenOutside: boolean | SharedValue<boolean>;
```

When `true` the handler will [cancel](/docs/fundamentals/states-events#cancelled) or [fail](/docs/fundamentals/states-events#failed) recognition (depending on its current state) whenever the finger leaves the area of the connected view.
Default value of this property is different depending on the handler type.
Most handlers' `shouldCancelWhenOutside` property defaults to `false` except for the [`LongPressGesture`](/docs/gestures/long-press-gesture) and [`TapGesture`](/docs/gestures/tap-gesture) which default to `true`.

### `hitSlop(settings)`
Most handlers' `shouldCancelWhenOutside` property defaults to `false` except for the [`LongPressGesture`](/docs/gestures/use-long-press-gesture) and [`TapGesture`](/docs/gestures/use-tap-gesture) which default to `true`.

### hitSlop

```ts
hitSlop: HitSlop | SharedValue<HitSlop>;
```

```ts
type HitSlop =
| number
| null
| undefined
| Partial<
Record<
'left' | 'right' | 'top' | 'bottom' | 'vertical' | 'horizontal',
number
>
>
| Record<'width' | 'left', number>
| Record<'width' | 'right', number>
| Record<'height' | 'top', number>
| Record<'height' | 'bottom', number>;
```

This parameter enables control over what part of the connected view area can be used to [begin](/docs/fundamentals/states-events#began) recognizing the gesture.
When a negative number is provided the bounds of the view will reduce the area by the given number of points in each of the sides evenly.
Expand All @@ -27,42 +56,65 @@ Specifying `width` or `height` is useful if we only want the gesture to activate

**IMPORTANT:** Note that this parameter is primarily designed to reduce the area where gesture can activate. Hence it is only supported for all the values (except `width` and `height`) to be non positive (0 or lower). Although on Android it is supported for the values to also be positive and therefore allow to expand beyond view bounds but not further than the parent view bounds. To achieve this effect on both platforms you can use React Native's View [hitSlop](https://reactnative.dev/docs/view.html#hitslop) property.

### `withRef(ref)`
### testID

Sets a ref to the gesture object, allowing for interoperability with the old
API.

### `withTestId(testID)`
```ts
testID: string;
```

Sets a `testID` property for gesture object, allowing for querying for it in tests.

### `cancelsTouchesInView(value)` (**iOS only**)
### cancelsTouchesInView (**iOS only**)

```ts
cancelsTouchesInView: boolean | SharedValue<boolean>;
```

Accepts a boolean value.
When `true`, the gesture will cancel touches for native UI components (`UIButton`, `UISwitch`, etc) it's attached to when it becomes [`ACTIVE`](/docs/fundamentals/states-events#active).
Default value is `true`.

### `runOnJS(value: boolean)`
### runOnJS

```ts
runOnJS: boolean | SharedValue<boolean>;
```

When `react-native-reanimated` is installed, the callbacks passed to the gestures are automatically workletized and run on the UI thread when called. This option allows for changing this behavior: when `true`, all the callbacks will be run on the JS thread instead of the UI thread, regardless of whether they are worklets or not.
Defaults to `false`.

### `simultaneousWithExternalGesture(otherGesture1, otherGesture2, ...)`
### simultaneousWith

```ts
simultaneousWith: Gesture | Gesture[]
```

Adds a gesture that should be recognized simultaneously with this one.

**IMPORTANT:** Note that this method only marks the relation between gestures, without [composing them](/docs/fundamentals/gesture-composition). [`GestureDetector`](/docs/gestures/gesture-detector) will not recognize the `otherGestures` and it needs to be added to another detector in order to be recognized.

### `requireExternalGestureToFail(otherGesture1, otherGesture2, ...)`
### requireToFail

```ts
requireToFail: Gesture | Gesture[]
```

Adds a relation requiring another gesture to fail, before this one can activate.

### `blocksExternalGesture(otherGesture1, otherGesture2, ...)`
### block

```ts
block: Gesture | Gesture[]
```

Adds a relation that makes other gestures wait with activation until this gesture fails (or doesn't start at all).

**IMPORTANT:** Note that this method only marks the relation between gestures, without [composing them](/docs/fundamentals/gesture-composition).[`GestureDetector`](/docs/gestures/gesture-detector) will not recognize the `otherGestures` and it needs to be added to another detector in order to be recognized.

### `activeCursor(value)` (Web only)
### activeCursor

```ts
activeCursor: ActiveCursor | SharedValue<ActiveCursor>;
```

This parameter allows to specify which cursor should be used when gesture activates. Supports all CSS cursor values (e.g. `"grab"`, `"zoom-in"`). Default value is set to `"auto"`.
This parameter allows to specify which cursor should be used when gesture activates. Supports all [CSS cursor values](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/cursor#keyword) (e.g. `"grab"`, `"zoom-in"`). Default value is set to `"auto"`.
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
### Event attributes common to all gestures:

### `state`
### numberOfPointers

Current [state](/docs/fundamentals/states-events) of the handler. Expressed as one of the constants exported under `State` object by the library.

### `numberOfPointers`
```ts
numberOfPointers: number;
```

Represents the number of pointers (fingers) currently placed on the screen.

### `pointerType`
### pointerType

```ts
pointerType: PointerType;
```

Indicates the type of pointer device in use. This value is represented by the `PointerType` enum, which includes the following fields:
```ts
enum PointerType {
TOUCH,
STYLUS,
MOUSE,
KEY,
OTHER,
}
```

- `TOUCH` - represents finger
- `STYLUS` - represents stylus or digital pen
- `MOUSE` - represents computer mouse
- `KEY` - represents keyboard
- `OTHER` - represents unknown device type that is not relevant
Indicates the type of pointer device in use.
Loading