ListHandle
What a List ref holds: its native list, and methods that scroll it to an item too.
Utilização
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>} />
</>
);
}Declaração do tipo
export interface ListHandle extends ScrollHandle {
scrollToIndex(params: ScrollToIndexOptions): void;
scrollToItem(params: Omit<ScrollToIndexOptions, 'index'> & { item: unknown }): void;
}Membros 13
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
scrollToIndex | (params: ScrollToIndexOptions) => void | Sim | — |
scrollToItem | (params: Omit<ScrollToIndexOptions, "index"> & { item: unknown;}) => void | Sim | — |
scrollTo | (params: { offset: number; animated?: boolean;} | { page: number; animated?: boolean;}) => void | Sim | 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 | Sim | Scrolls to the end of the content, including what the same update added. |
idsó de leitura | string | Sim | — |
parentsó de leitura | ElementHandle | Sim | — |
childrensó de leitura | ElementHandle[] | Sim | — |
focus | () => void | Sim | — |
blur | () => void | Sim | — |
setProperty | <K extends keyof ElementProperties>(key: K, value: ElementProperties[K] | null) => void | Sim | 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 | Sim | — |
removeEventListener | (type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean;}) => void | Sim | — |
dispatchEvent | (event: { type: string; bubbles?: boolean; cancelable?: boolean;}) => boolean | Sim | 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 — assinaturas de método
Assinaturas
(params: ScrollToIndexOptions): voidParâmetros
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
params | ScrollToIndexOptions | Sim | — |
Devolve
void
scrollToItem — assinaturas de método
Assinaturas
(params: Omit<ScrollToIndexOptions, "index"> & { item: unknown; }): voidParâmetros
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
params | Omit<ScrollToIndexOptions, "index"> & { item: unknown;} | Sim | — |
Devolve
void
scrollTo — assinaturas de método
Assinaturas
(params: { offset: number; animated?: boolean; } | { page: number; animated?: boolean; }): voidParâmetros
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
params | { offset: number; animated?: boolean;} | { page: number; animated?: boolean;} | Sim | — |
Devolve
void
scrollToEnd — assinaturas de método
Assinaturas
(params?: { animated?: boolean; }): voidParâmetros
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
params | { animated?: boolean;} | Não | — |
Devolve
void
focus — assinaturas de método
Assinaturas
(): voidParâmetros
Sem parâmetros.
Devolve
void
blur — assinaturas de método
Assinaturas
(): voidParâmetros
Sem parâmetros.
Devolve
void
setProperty — assinaturas de método
Assinaturas
<K extends keyof ElementProperties>(key: K, value: ElementProperties[K] | null): voidParâmetros de tipo
| Nome | Restrição | Predefinição |
|---|---|---|
K | keyof ElementProperties | — |
Parâmetros
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
key | K | Sim | — |
value | ElementProperties[K] | Sim | — |
Devolve
void
addEventListener — assinaturas de método
Assinaturas
(type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean; once?: boolean; signal?: AbortSignal; }): voidParâmetros
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
type | string | Sim | — |
fn | (e: KuitoNativeEvent) => void | Sim | — |
options | boolean | { capture?: boolean; once?: boolean; signal?: AbortSignal;} | Não | — |
Devolve
void
removeEventListener — assinaturas de método
Assinaturas
(type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean; }): voidParâmetros
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
type | string | Sim | — |
fn | (e: KuitoNativeEvent) => void | Sim | — |
options | boolean | { capture?: boolean;} | Não | — |
Devolve
void
dispatchEvent — assinaturas de método
Assinaturas
(event: { type: string; bubbles?: boolean; cancelable?: boolean; }): booleanParâmetros
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
event | { type: string; bubbles?: boolean; cancelable?: boolean;} | Sim | — |
Devolve
boolean
Gerado a partir das declarações TypeScript públicas: assinaturas, props e predefinições vêm da fonte verificada, as descrições da sua JSDoc. Nenhuma predefinição é inventada.