ListHandle
What a List ref holds: its native list, and methods that scroll it to an item too.
Utilisation
Scroll a list to a particular item.
// Scroll a list to a particular item.
import { Button, List, Text, ref, type ListHandle, type ScrollToIndexOptions } from 'kuito';
function Chapters(props: { titles: string[]; current: number }) {
const list = ref<ListHandle>();
// Centers the current chapter, with room for the header above it.
const toCurrent: ScrollToIndexOptions = {
index: props.current,
align: 0.5,
margin: 16,
animated: true,
};
return (
<>
<Button onPress={() => list.current?.scrollToIndex(toCurrent)}>Current chapter</Button>
<List ref={list} data={props.titles} renderItem={({ item }) => <Text>{item}</Text>} />
</>
);
}Déclaration du type
export interface ListHandle extends ScrollHandle {
scrollToIndex(params: ScrollToIndexOptions): void;
scrollToItem(params: Omit<ScrollToIndexOptions, 'index'> & { item: unknown }): void;
}Membres 13
| Nom | Type | Requis | Description |
|---|---|---|---|
scrollToIndex | (params: ScrollToIndexOptions) => void | Oui | — |
scrollToItem | (params: Omit<ScrollToIndexOptions, "index"> & { item: unknown;}) => void | Oui | — |
scrollTo | (params: { offset: number; animated?: boolean;} | { page: number; animated?: boolean;}) => void | Oui | Scrolls to offset points along the view's axis, or to page, a whole
view length each from 0, as paging rests; animated by default. |
scrollToEnd | (params?: { animated?: boolean;}) => void | Oui | Scrolls to the end of the content, including what the same update added. |
idlecture seule | string | Oui | — |
parentlecture seule | ElementHandle | Oui | — |
childrenlecture seule | ElementHandle[] | Oui | — |
focus | () => void | Oui | — |
blur | () => void | Oui | — |
setProperty | <K extends keyof ElementProperties>(key: K, value: ElementProperties[K] | null) => void | Oui | Sets a native prop on the view now, until its binding writes it again. |
addEventListener | (type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean; once?: boolean; signal?: AbortSignal;}) => void | Oui | — |
removeEventListener | (type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean;}) => void | Oui | — |
dispatchEvent | (event: { type: string; bubbles?: boolean; cancelable?: boolean;}) => boolean | Oui | Sends an event through the tree, capture to bubble, as a native one travels:
a KuitoCustomEvent, or any object with a type. False when a listener
called preventDefault() on a cancelable event. |
scrollToIndex — signatures de méthode
Signatures
(params: ScrollToIndexOptions): voidParamètres
| Nom | Type | Requis | Description |
|---|---|---|---|
params | ScrollToIndexOptions | Oui | — |
Retourne
void
scrollToItem — signatures de méthode
Signatures
(params: Omit<ScrollToIndexOptions, "index"> & { item: unknown; }): voidParamètres
| Nom | Type | Requis | Description |
|---|---|---|---|
params | Omit<ScrollToIndexOptions, "index"> & { item: unknown;} | Oui | — |
Retourne
void
scrollTo — signatures de méthode
Signatures
(params: { offset: number; animated?: boolean; } | { page: number; animated?: boolean; }): voidParamètres
| Nom | Type | Requis | Description |
|---|---|---|---|
params | { offset: number; animated?: boolean;} | { page: number; animated?: boolean;} | Oui | — |
Retourne
void
scrollToEnd — signatures de méthode
Signatures
(params?: { animated?: boolean; }): voidParamètres
| Nom | Type | Requis | Description |
|---|---|---|---|
params | { animated?: boolean;} | Non | — |
Retourne
void
focus — signatures de méthode
Signatures
(): voidParamètres
Aucun paramètre.
Retourne
void
blur — signatures de méthode
Signatures
(): voidParamètres
Aucun paramètre.
Retourne
void
setProperty — signatures de méthode
Signatures
<K extends keyof ElementProperties>(key: K, value: ElementProperties[K] | null): voidParamètres de type
| Nom | Contrainte | Par défaut |
|---|---|---|
K | keyof ElementProperties | — |
Paramètres
| Nom | Type | Requis | Description |
|---|---|---|---|
key | K | Oui | — |
value | ElementProperties[K] | Oui | — |
Retourne
void
addEventListener — signatures de méthode
Signatures
(type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean; once?: boolean; signal?: AbortSignal; }): voidParamètres
| Nom | Type | Requis | Description |
|---|---|---|---|
type | string | Oui | — |
fn | (e: KuitoNativeEvent) => void | Oui | — |
options | boolean | { capture?: boolean; once?: boolean; signal?: AbortSignal;} | Non | — |
Retourne
void
removeEventListener — signatures de méthode
Signatures
(type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean; }): voidParamètres
| Nom | Type | Requis | Description |
|---|---|---|---|
type | string | Oui | — |
fn | (e: KuitoNativeEvent) => void | Oui | — |
options | boolean | { capture?: boolean;} | Non | — |
Retourne
void
dispatchEvent — signatures de méthode
Signatures
(event: { type: string; bubbles?: boolean; cancelable?: boolean; }): booleanParamètres
| Nom | Type | Requis | Description |
|---|---|---|---|
event | { type: string; bubbles?: boolean; cancelable?: boolean;} | Oui | — |
Retourne
boolean
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.