Skip to content

Commit ad18fcd

Browse files
Add mobile navigation offset synchronization and improve layout handling
1 parent f60c9a8 commit ad18fcd

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

src/app/gameRenderer.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ export function createGameRenderer({
103103
initLocVisual();
104104
initTeamVisual();
105105
initMobileNav();
106+
syncMobileNavOffset();
107+
window.addEventListener("resize", syncMobileNavOffset);
106108
codeBackground.init();
107109
managementPanels.init();
108110
setMobileScreen("play");
@@ -205,6 +207,7 @@ export function createGameRenderer({
205207
function setMobileScreen(screenId: MobileScreenId): void {
206208
activeMobileScreen = screenId;
207209
elements.shell.setAttribute("data-mobile-screen", screenId);
210+
syncMobileNavOffset();
208211

209212
elements.mobileNav
210213
.querySelectorAll<HTMLButtonElement>("button[data-screen-id]")
@@ -215,6 +218,11 @@ export function createGameRenderer({
215218
});
216219
}
217220

221+
function syncMobileNavOffset(): void {
222+
const navHeight = elements.mobileNav.offsetHeight || 76;
223+
elements.shell.style.setProperty("--mobile-nav-offset", `${navHeight + 20}px`);
224+
}
225+
218226
function render(state: GameState): void {
219227
const nowMs = Date.now();
220228
audio.setMusicRunning(!isGameOver(state));

src/lib/css/styles.css

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ body.alarm-tech-debt::after {
185185
width: min(1450px, 100%);
186186
height: 100%;
187187
position: relative;
188+
--mobile-nav-offset: 96px;
188189
-webkit-user-select: none;
189190
user-select: none;
190191
}
@@ -1418,8 +1419,10 @@ input {
14181419
height: 100%;
14191420
overflow-x: hidden;
14201421
overflow-y: auto;
1421-
padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
1422-
scroll-padding-bottom: calc(108px + env(safe-area-inset-bottom, 0px));
1422+
padding-bottom: calc(var(--mobile-nav-offset) + env(safe-area-inset-bottom));
1423+
scroll-padding-bottom: calc(
1424+
var(--mobile-nav-offset) + env(safe-area-inset-bottom) + 12px
1425+
);
14231426
-webkit-overflow-scrolling: touch;
14241427
}
14251428

0 commit comments

Comments
 (0)