Callbacks
Callbacks for what needs JavaScript; the compiler places each one.
Utilisation
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 })]} />;Déclaration du type
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;
}Membres 3
| Nom | Type | Requis | Description |
|---|---|---|---|
onStart | (event: Event) => void | Non | It activated. |
onChange | (event: Change) => void | Non | It moved, with the change since the last move. |
onEnd | (event: Event, success: boolean) => void | Non | It ended after activating: success is false when it was cancelled. |
onStart — signatures de méthode
Signatures
(event: Event): voidParamètres
| Nom | Type | Requis | Description |
|---|---|---|---|
event | Event | Oui | — |
Retourne
void
onChange — signatures de méthode
Signatures
(event: Change): voidParamètres
| Nom | Type | Requis | Description |
|---|---|---|---|
event | Change | Oui | — |
Retourne
void
onEnd — signatures de méthode
Signatures
(event: Event, success: boolean): voidParamètres
| Nom | Type | Requis | Description |
|---|---|---|---|
event | Event | Oui | — |
success | boolean | Oui | — |
Retourne
void
Généré depuis les déclarations TypeScript publiques : signatures, props et valeurs par défaut viennent de la source vérifiée, les descriptions de sa JSDoc. Aucune valeur par défaut n'est inventée.