ScrollToIndexOptions
Says which item a List scrolls to and where in the viewport the item lands.
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 ScrollToIndexOptions {
index: number;
animated?: boolean;
/** Where the item lands: 0 at the start of the list, 0.5 centered, 1 at the end. */
align?: number;
/** Points to keep before the item, as CSS's `scroll-margin`. */
margin?: number;
}Mitglieder 4
| Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
index | number | Ja | — |
animated | boolean | Nein | — |
align | number | Nein | Where the item lands: 0 at the start of the list, 0.5 centered, 1 at the end. |
margin | number | Nein | Points to keep before the item, as CSS's scroll-margin. |
Generiert aus den öffentlichen TypeScript-Deklarationen: Signaturen, Props und Standardwerte stammen aus der geprüften Quelle, Beschreibungen aus deren JSDoc. Kein Standardwert ist erfunden.