Skip to content

Commit 52ec7b7

Browse files
committed
fix incorrect jumping/scaling on mobile
1 parent 7224cbe commit 52ec7b7

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

src/app.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="utf-8" >
55
<link rel="icon" href="%sveltekit.assets%/wan.webp" >
6-
<meta name="viewport" content="width=device-width" >
6+
<meta name="viewport" content="width=device-width, initial-scale=1" >
77
<link rel="manifest" href="/site.webmanifest">
88
<link rel="apple-touch-icon" href="/wan-ios-logo.png">
99
<meta name="darkreader-lock">

src/routes/+page.svelte

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,15 @@
136136
let addSpace = $state(false);
137137
function checkHeight() {
138138
if(!browser || !mainContainer) return;
139-
if(mainContainer.scrollHeight > window.innerHeight-50) {
139+
// Use hysteresis to prevent oscillation when window.innerHeight fluctuates
140+
// due to mobile browser chrome showing/hiding. The spacer is outside
141+
// mainContainer so it doesn't affect scrollHeight, but we still need
142+
// different thresholds to avoid toggling on small viewport changes.
143+
const threshold = addSpace ? 100 : 50;
144+
if(mainContainer.scrollHeight > window.innerHeight - threshold) {
140145
outerContainer.classList.remove("items-center")
141146
outerContainer.classList.add("too-short")
142-
addSpace = true // So that there is some space at the bottom when scrolling. for some stupid reason padding doesnt work here
147+
addSpace = true
143148
if(dev) console.debug("too short")
144149
} else {
145150
outerContainer.classList.add("items-center")
@@ -406,10 +411,10 @@
406411
</Accordion>
407412
</div>
408413
{/if}
409-
{#if addSpace}
410-
<div class="h-16"></div>
411-
{/if}
412414
</div>
415+
{#if addSpace}
416+
<div class="h-16"></div>
417+
{/if}
413418
</div>
414419

415420
{#if isFrame}
@@ -477,7 +482,6 @@
477482
478483
.container {
479484
padding: 5em 1em 1em;
480-
transition: padding 0.4s;
481485
}
482486
483487
.lateness-stats {

0 commit comments

Comments
 (0)