mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-09-27 05:38:09 -05:00
24 lines
566 B
TypeScript
24 lines
566 B
TypeScript
import { invariant } from "~/utils/invariant";
|
|
|
|
export const KEYBOARD_HEIGHT = 300;
|
|
|
|
export function openKeyboard() {
|
|
const viewport = window.visualViewport;
|
|
invariant(viewport);
|
|
|
|
const shrunk = viewport.height - KEYBOARD_HEIGHT;
|
|
Object.defineProperty(viewport, "height", {
|
|
configurable: true,
|
|
get: () => shrunk,
|
|
});
|
|
viewport.dispatchEvent(new Event("resize"));
|
|
}
|
|
|
|
export function closeKeyboard() {
|
|
const viewport = window.visualViewport;
|
|
invariant(viewport);
|
|
|
|
Reflect.deleteProperty(viewport, "height");
|
|
viewport.dispatchEvent(new Event("resize"));
|
|
}
|