ListHandle
What a List ref holds: its native list, and methods that scroll it to an item too.
Verwendung
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>} />
</>
);
}Typdeklaration
export interface ListHandle extends ScrollHandle {
scrollToIndex(params: ScrollToIndexOptions): void;
scrollToItem(params: Omit<ScrollToIndexOptions, 'index'> & { item: unknown }): void;
}Mitglieder 13
| Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
scrollToIndex | (params: ScrollToIndexOptions) => void | Ja | — |
scrollToItem | (params: Omit<ScrollToIndexOptions, "index"> & { item: unknown;}) => void | Ja | — |
scrollTo | (params: { offset: number; animated?: boolean;} | { page: number; animated?: boolean;}) => void | Ja | 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 | Ja | Scrolls to the end of the content, including what the same update added. |
idschreibgeschützt | string | Ja | — |
parentschreibgeschützt | ElementHandle | Ja | — |
childrenschreibgeschützt | ElementHandle[] | Ja | — |
focus | () => void | Ja | — |
blur | () => void | Ja | — |
setProperty | <K extends keyof ElementProperties>(key: K, value: ElementProperties[K] | null) => void | Ja | 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 | Ja | — |
removeEventListener | (type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean;}) => void | Ja | — |
dispatchEvent | (event: { type: string; bubbles?: boolean; cancelable?: boolean;}) => boolean | Ja | 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 — Methodensignaturen
Signaturen
(params: ScrollToIndexOptions): voidParameter
| Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
params | ScrollToIndexOptions | Ja | — |
Rückgabe
void
scrollToItem — Methodensignaturen
Signaturen
(params: Omit<ScrollToIndexOptions, "index"> & { item: unknown; }): voidParameter
| Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
params | Omit<ScrollToIndexOptions, "index"> & { item: unknown;} | Ja | — |
Rückgabe
void
scrollTo — Methodensignaturen
Signaturen
(params: { offset: number; animated?: boolean; } | { page: number; animated?: boolean; }): voidParameter
| Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
params | { offset: number; animated?: boolean;} | { page: number; animated?: boolean;} | Ja | — |
Rückgabe
void
scrollToEnd — Methodensignaturen
Signaturen
(params?: { animated?: boolean; }): voidParameter
| Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
params | { animated?: boolean;} | Nein | — |
Rückgabe
void
focus — Methodensignaturen
Signaturen
(): voidParameter
Keine Parameter.
Rückgabe
void
blur — Methodensignaturen
Signaturen
(): voidParameter
Keine Parameter.
Rückgabe
void
setProperty — Methodensignaturen
Signaturen
<K extends keyof ElementProperties>(key: K, value: ElementProperties[K] | null): voidTypparameter
| Name | Einschränkung | Standard |
|---|---|---|
K | keyof ElementProperties | — |
Parameter
| Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
key | K | Ja | — |
value | ElementProperties[K] | Ja | — |
Rückgabe
void
addEventListener — Methodensignaturen
Signaturen
(type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean; once?: boolean; signal?: AbortSignal; }): voidParameter
| Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
type | string | Ja | — |
fn | (e: KuitoNativeEvent) => void | Ja | — |
options | boolean | { capture?: boolean; once?: boolean; signal?: AbortSignal;} | Nein | — |
Rückgabe
void
removeEventListener — Methodensignaturen
Signaturen
(type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean; }): voidParameter
| Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
type | string | Ja | — |
fn | (e: KuitoNativeEvent) => void | Ja | — |
options | boolean | { capture?: boolean;} | Nein | — |
Rückgabe
void
dispatchEvent — Methodensignaturen
Signaturen
(event: { type: string; bubbles?: boolean; cancelable?: boolean; }): booleanParameter
| Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
event | { type: string; bubbles?: boolean; cancelable?: boolean;} | Ja | — |
Rückgabe
boolean
Generiert aus den öffentlichen TypeScript-Deklarationen: Signaturen, Props und Standardwerte stammen aus der geprüften Quelle, Beschreibungen aus deren JSDoc. Kein Standardwert ist erfunden.