Callbacks
Callbacks for what needs JavaScript; the compiler places each one.
Usage
Add haptic feedback to a gesture.
// Add haptic feedback to a gesture.
import { Box, haptics, pan, type Callbacks, type PanChangeEvent, type PanEvent } from 'kuito';
// Shared feedback for every draggable in the app.
const feedback: Callbacks<PanEvent, PanChangeEvent> = {
onStart: () => void haptics.selection(),
onEnd: (_, success) => void (success && haptics.impact('light')),
};
<Box gestures={[pan({ axis: 'x', ...feedback })]} />;Type declaration
export interface Callbacks<Event, Change> {
/** It activated. */
onStart?: (event: Event) => void;
/** It moved, with the change since the last move. */
onChange?: (event: Change) => void;
/** It ended after activating: `success` is false when it was cancelled. */
onEnd?: (event: Event, success: boolean) => void;
}Members 3
| Name | Type | Required | Description |
|---|---|---|---|
onStart | (event: Event) => void | No | It activated. |
onChange | (event: Change) => void | No | It moved, with the change since the last move. |
onEnd | (event: Event, success: boolean) => void | No | It ended after activating: success is false when it was cancelled. |
onStart — method signatures
Signatures
(event: Event): voidParameters
| Name | Type | Required | Description |
|---|---|---|---|
event | Event | Yes | — |
Returns
void
onChange — method signatures
Signatures
(event: Change): voidParameters
| Name | Type | Required | Description |
|---|---|---|---|
event | Change | Yes | — |
Returns
void
onEnd — method signatures
Signatures
(event: Event, success: boolean): voidParameters
| Name | Type | Required | Description |
|---|---|---|---|
event | Event | Yes | — |
success | boolean | Yes | — |
Returns
void
Generated from the public TypeScript declarations: signatures, props and defaults come from the checked source, descriptions from its JSDoc. No defaults are invented.