Verwendung

Scroll after adding content

tsx
import { Button, For, ref, Scroll, signal, Text, VStack } from 'kuito';
import type { ScrollHandle } from 'kuito';

function Chat() {
  const messages = signal<string[]>([]);
  const thread = ref<ScrollHandle>();

  function send() {
    messages.value = [...messages.value, 'Message ' + (messages.value.length + 1)];
    thread.current?.scrollToEnd();
  }

  return (
    <VStack flex={1} gap={8}>
      <Scroll ref={thread} flex={1}>
        <For each={messages}>{(message) => <Text>{message}</Text>}</For>
      </Scroll>
      <Button onPress={send}>Send</Button>
    </VStack>
  );
}

Typdeklaration

ts
export interface ScrollHandle extends ElementHandle {
  /**
   * 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.
   */
  scrollTo(
    params: { offset: number; animated?: boolean } | { page: number; animated?: boolean },
  ): void;
  /** Scrolls to the end of the content, including what the same update added. */
  scrollToEnd(params?: { animated?: boolean }): void;
}

Mitglieder 11

NameTypErforderlichBeschreibung
scrollTo(params: { offset: number; animated?: boolean;} | { page: number; animated?: boolean;}) => voidJaScrolls 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;}) => voidJaScrolls to the end of the content, including what the same update added.
idschreibgeschütztstringJa—
parentschreibgeschütztElementHandleJa—
childrenschreibgeschütztElementHandle[]Ja—
focus() => voidJa—
blur() => voidJa—
setProperty<K extends keyof ElementProperties>(key: K, value: ElementProperties[K] | null) => voidJaSets 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;}) => voidJa—
removeEventListener(type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean;}) => voidJa—
dispatchEvent(event: { type: string; bubbles?: boolean; cancelable?: boolean;}) => booleanJaSends 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.
scrollTo — Methodensignaturen

Signaturen

ts
(params: { offset: number; animated?: boolean; } | { page: number; animated?: boolean; }): void

Parameter

NameTypErforderlichBeschreibung
params{ offset: number; animated?: boolean;} | { page: number; animated?: boolean;}Ja—

Rückgabe

void

scrollToEnd — Methodensignaturen

Signaturen

ts
(params?: { animated?: boolean; }): void

Parameter

NameTypErforderlichBeschreibung
params{ animated?: boolean;}Nein—

Rückgabe

void

focus — Methodensignaturen

Signaturen

ts
(): void

Parameter

Keine Parameter.

Rückgabe

void

blur — Methodensignaturen

Signaturen

ts
(): void

Parameter

Keine Parameter.

Rückgabe

void

setProperty — Methodensignaturen

Signaturen

ts
<K extends keyof ElementProperties>(key: K, value: ElementProperties[K] | null): void

Typparameter

NameEinschränkungStandard
Kkeyof ElementProperties—

Parameter

NameTypErforderlichBeschreibung
keyKJa—
valueElementProperties[K]Ja—

Rückgabe

void

addEventListener — Methodensignaturen

Signaturen

ts
(type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean; once?: boolean; signal?: AbortSignal; }): void

Parameter

NameTypErforderlichBeschreibung
typestringJa—
fn(e: KuitoNativeEvent) => voidJa—
optionsboolean | { capture?: boolean; once?: boolean; signal?: AbortSignal;}Nein—

Rückgabe

void

removeEventListener — Methodensignaturen

Signaturen

ts
(type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean; }): void

Parameter

NameTypErforderlichBeschreibung
typestringJa—
fn(e: KuitoNativeEvent) => voidJa—
optionsboolean | { capture?: boolean;}Nein—

Rückgabe

void

dispatchEvent — Methodensignaturen

Signaturen

ts
(event: { type: string; bubbles?: boolean; cancelable?: boolean; }): boolean

Parameter

NameTypErforderlichBeschreibung
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.