keyboard.frame
The shown keyboard's frame on screen, in points; null while it is hidden. A motion value the UI thread moves from the keyboard's own events, so a view bound to it moves without the JS thread; read it anywhere.
Utilisation
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>
);
}Propriétés et méthodes 3
| Nom | Type | Requis | Description |
|---|---|---|---|
value | KeyboardFrame | Oui | A value moves there now; an animation (timing, spring, decay, ...) moves it there. |
follows | (source: GestureSource | Readable<KeyboardFrame>) => Motion<KeyboardFrame> | Oui | 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: KeyboardFrame) => U) => Derived<U> | Oui | A value computed from this one, on the UI thread. |
follows — signatures de méthode
Signatures
(source: GestureSource | Readable<KeyboardFrame>): Motion<KeyboardFrame>Paramètres
| Nom | Type | Requis | Description |
|---|---|---|---|
source | GestureSource | Readable<KeyboardFrame> | Oui | — |
Retourne
map — signatures de méthode
Signatures
<U>(fn: (value: KeyboardFrame) => U): Derived<U>Paramètres de type
| Nom | Contrainte | Par défaut |
|---|---|---|
U | — | — |
Paramètres
| Nom | Type | Requis | Description |
|---|---|---|---|
fn | (value: KeyboardFrame) => U | Oui | — |
Retourne
Derived<U>
Généré depuis les déclarations TypeScript publiques : signatures, props et valeurs par défaut viennent de la source vérifiée, les descriptions de sa JSDoc. Aucune valeur par défaut n'est inventée.