Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/components/TokenGate.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
place-items: center;
min-height: 100%;
min-height: 100dvh;
/* the visible height (lib/viewport.ts): with the keyboard up the card is centred
above it, so iOS has no field to scroll into view */
min-height: var(--app-height, 100dvh);
padding: calc(var(--space-4) + env(safe-area-inset-top, 0px)) calc(var(--space-4) + env(safe-area-inset-right, 0px))
calc(var(--space-4) + env(safe-area-inset-bottom, 0px)) calc(var(--space-4) + env(safe-area-inset-left, 0px));
background: var(--bg);
Expand Down
7 changes: 6 additions & 1 deletion src/lib/viewport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,19 @@
* and pinning the page at (0, 0) keeps header, terminal and key bar in view.
* Chrome resizes the layout viewport itself (interactive-widget=resizes-content
* in index.html), so there the same value changes nothing.
*
* Only the shell (.app) is pinned. The token gate sizes itself to the same height
* and is otherwise a plain page: pinning it fought iOS scrolling the focused field
* into view, and a second tap on the field (to paste) landed after the page jumped,
* off the field, which dismissed the keyboard.
*/

const viewport = window.visualViewport;

if (viewport) {
const sync = (): void => {
document.documentElement.style.setProperty("--app-height", `${Math.round(viewport.height)}px`);
window.scrollTo(0, 0);
if (document.querySelector(".app") !== null) window.scrollTo(0, 0);
};
viewport.addEventListener("resize", sync);
viewport.addEventListener("scroll", sync);
Expand Down