Verrouille chrono et cube au viewport mobile

This commit is contained in:
2026-04-12 18:02:26 +02:00
parent de962eb8a0
commit 9444b9b64f
3 changed files with 206 additions and 1 deletions

16
app.js
View File

@@ -37,6 +37,17 @@ const MODES = {
},
};
syncViewportHeight();
window.addEventListener("resize", syncViewportHeight);
window.addEventListener("pageshow", syncViewportHeight);
window.addEventListener("orientationchange", syncViewportHeight);
window.visualViewport?.addEventListener("resize", syncViewportHeight);
window.visualViewport?.addEventListener("scroll", syncViewportHeight);
window.setTimeout(syncViewportHeight, 0);
window.requestAnimationFrame(() => {
window.requestAnimationFrame(syncViewportHeight);
});
let match = readStoredMatch();
let dirty = false;
@@ -79,6 +90,11 @@ switch (PAGE) {
break;
}
function syncViewportHeight() {
const viewportHeight = window.visualViewport?.height ?? window.innerHeight;
document.documentElement.style.setProperty("--app-viewport-height", `${Math.round(viewportHeight)}px`);
}
function initSetupPage() {
const form = document.querySelector("#setupForm");
const summary = document.querySelector("#setupSummary");