ListHandle
What a List ref holds: its native list, and methods that scroll it to an item too.
Usage
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>} />
</>
);
}Type declaration
export interface ListHandle extends ScrollHandle {
scrollToIndex(params: ScrollToIndexOptions): void;
scrollToItem(params: Omit<ScrollToIndexOptions, 'index'> & { item: unknown }): void;
}Members 13
| Name | Type | Required | Description |
|---|---|---|---|
scrollToIndex | (params: ScrollToIndexOptions) => void | Yes | — |
scrollToItem | (params: Omit<ScrollToIndexOptions, "index"> & { item: unknown;}) => void | Yes | — |
scrollTo | (params: { offset: number; animated?: boolean;} | { page: number; animated?: boolean;}) => void | Yes | 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 | Yes | Scrolls to the end of the content, including what the same update added. |
idreadonly | string | Yes | — |
parentreadonly | ElementHandle | Yes | — |
childrenreadonly | ElementHandle[] | Yes | — |
focus | () => void | Yes | — |
blur | () => void | Yes | — |
setProperty | <K extends keyof ElementProperties>(key: K, value: ElementProperties[K] | null) => void | Yes | 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 | Yes | — |
removeEventListener | (type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean;}) => void | Yes | — |
dispatchEvent | (event: { type: string; bubbles?: boolean; cancelable?: boolean;}) => boolean | Yes | 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 — method signatures
Signatures
(params: ScrollToIndexOptions): voidParameters
| Name | Type | Required | Description |
|---|---|---|---|
params | ScrollToIndexOptions | Yes | — |
Returns
void
scrollToItem — method signatures
Signatures
(params: Omit<ScrollToIndexOptions, "index"> & { item: unknown; }): voidParameters
| Name | Type | Required | Description |
|---|---|---|---|
params | Omit<ScrollToIndexOptions, "index"> & { item: unknown;} | Yes | — |
Returns
void
scrollTo — method signatures
Signatures
(params: { offset: number; animated?: boolean; } | { page: number; animated?: boolean; }): voidParameters
| Name | Type | Required | Description |
|---|---|---|---|
params | { offset: number; animated?: boolean;} | { page: number; animated?: boolean;} | Yes | — |
Returns
void
scrollToEnd — method signatures
Signatures
(params?: { animated?: boolean; }): voidParameters
| Name | Type | Required | Description |
|---|---|---|---|
params | { animated?: boolean;} | No | — |
Returns
void
focus — method signatures
Signatures
(): voidParameters
No parameters.
Returns
void
blur — method signatures
Signatures
(): voidParameters
No parameters.
Returns
void
setProperty — method signatures
Signatures
<K extends keyof ElementProperties>(key: K, value: ElementProperties[K] | null): voidType parameters
| Name | Constraint | Default |
|---|---|---|
K | keyof ElementProperties | — |
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
key | K | Yes | — |
value | ElementProperties[K] | Yes | — |
Returns
void
addEventListener — method signatures
Signatures
(type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean; once?: boolean; signal?: AbortSignal; }): voidParameters
| Name | Type | Required | Description |
|---|---|---|---|
type | string | Yes | — |
fn | (e: KuitoNativeEvent) => void | Yes | — |
options | boolean | { capture?: boolean; once?: boolean; signal?: AbortSignal;} | No | — |
Returns
void
removeEventListener — method signatures
Signatures
(type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean; }): voidParameters
| Name | Type | Required | Description |
|---|---|---|---|
type | string | Yes | — |
fn | (e: KuitoNativeEvent) => void | Yes | — |
options | boolean | { capture?: boolean;} | No | — |
Returns
void
dispatchEvent — method signatures
Signatures
(event: { type: string; bubbles?: boolean; cancelable?: boolean; }): booleanParameters
| Name | Type | Required | Description |
|---|---|---|---|
event | { type: string; bubbles?: boolean; cancelable?: boolean;} | Yes | — |
Returns
boolean
Generated from the public TypeScript declarations: signatures, props and defaults come from the checked source, descriptions from its JSDoc. No defaults are invented.