diff --git a/frontend/index.html b/frontend/index.html index e004457..0134879 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -3,7 +3,14 @@ - + + { + // Pinch-zoom shrinks the visual viewport too, and that is not a keyboard. + const covered = vv.scale > 1.01 ? 0 : window.innerHeight - vv.height - vv.offsetTop + const inset = covered > MIN_KEYBOARD ? Math.round(covered) : 0 + document.documentElement.style.setProperty('--kb-inset', `${inset}px`) + } + // resize fires as the keyboard animates in; scroll fires as the page pans + // under a keyboard that is already up, which moves offsetTop. + vv.addEventListener('resize', apply) + vv.addEventListener('scroll', apply) + apply() +} diff --git a/frontend/src/main.jsx b/frontend/src/main.jsx index ecba514..9350bb0 100644 --- a/frontend/src/main.jsx +++ b/frontend/src/main.jsx @@ -11,8 +11,11 @@ import Scripts from './pages/Scripts.jsx' import ScriptEditor from './pages/ScriptEditor.jsx' import Settings from './pages/Settings.jsx' import Chat from './pages/Chat.jsx' +import { trackKeyboardInset } from './keyboard.js' import './index.css' +trackKeyboardInset() + const router = createBrowserRouter([ { path: '/',