keyboard.height
How far the keyboard stands over the window's bottom now, in points; 0 while hidden. A motion value the keyboard moves every frame, as it animates and as a finger drags it down, so a view bound to it rides on the keyboard with no JavaScript (docs/keyboard.md#keyboard).
Verwendung
Dismiss and observe the keyboard
import { Box, Button, Text, VStack, keyboard } from 'kuito';
export default function KeyboardState() {
keyboard.frame.value; // { screenX, screenY, width, height } or null
// In a component, until it unmounts; elsewhere, until remove().
keyboard.watch('didShow', (event) => console.log(event.frame.height, event.duration));
return (
<VStack>
<Text>{keyboard.visible.value ? 'typing' : ''}</Text>
{/* Rides on the keyboard. */}
<Box translateY={keyboard.height.map((height) => -height)} />
<Button onPress={() => keyboard.dismiss()}>Done</Button>
</VStack>
);
}Eigenschaften und Methoden 3
| Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
value | number | Ja | A value moves there now; an animation (timing, spring, decay, ...) moves it there. |
follows | (source: Readable<number> | GestureSource) => Motion<number> | Ja | Moves with source on the UI thread, with no code: a gesture's field
(drag.x), another motion value or a derived one. Null stops it. |
map | <U>(fn: (value: number) => U) => Derived<U> | Ja | A value computed from this one, on the UI thread. |
follows — Methodensignaturen
Signaturen
(source: Readable<number> | GestureSource): Motion<number>Parameter
| Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
source | Readable<number> | GestureSource | Ja | — |
Rückgabe
Motion<number>
map — Methodensignaturen
Signaturen
<U>(fn: (value: number) => U): Derived<U>Typparameter
| Name | Einschränkung | Standard |
|---|---|---|
U | — | — |
Parameter
| Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
fn | (value: number) => U | Ja | — |
Rückgabe
Derived<U>
Generiert aus den öffentlichen TypeScript-Deklarationen: Signaturen, Props und Standardwerte stammen aus der geprüften Quelle, Beschreibungen aus deren JSDoc. Kein Standardwert ist erfunden.