From 89b8785a40f5ced765f9a2091bde84f448dd715e Mon Sep 17 00:00:00 2001 From: MechaCat02 Date: Sun, 17 May 2026 20:57:05 +0200 Subject: [PATCH] bugfix: reader-nav is fully fixed; no settle-on-scroll (0.21.3) --- backend/Cargo.lock | 2 +- backend/Cargo.toml | 2 +- frontend/package.json | 2 +- frontend/src/lib/styles/tokens.css | 8 +- frontend/src/routes/+layout.svelte | 10 ++- .../manga/[id]/chapter/[n]/+page.svelte | 82 +++++++++++++------ 6 files changed, 73 insertions(+), 33 deletions(-) diff --git a/backend/Cargo.lock b/backend/Cargo.lock index e844c03..18b4001 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -1033,7 +1033,7 @@ checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" [[package]] name = "mangalord" -version = "0.21.2" +version = "0.21.3" dependencies = [ "anyhow", "argon2", diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 7bb978c..3b2d8bf 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mangalord" -version = "0.21.2" +version = "0.21.3" edition = "2021" [lib] diff --git a/frontend/package.json b/frontend/package.json index 164feb5..32b2e81 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "mangalord-frontend", - "version": "0.21.2", + "version": "0.21.3", "private": true, "type": "module", "scripts": { diff --git a/frontend/src/lib/styles/tokens.css b/frontend/src/lib/styles/tokens.css index 2408b45..b1cad87 100644 --- a/frontend/src/lib/styles/tokens.css +++ b/frontend/src/lib/styles/tokens.css @@ -61,10 +61,12 @@ --icon-lg: 22px; /* App-frame heights (fixed-position bars at the top and bottom of - the viewport). Used by the layout + reader to reserve content - space and animate fullscreen mode. Recomputed once if the - header padding/font-size ever changes — keep in sync. */ + the viewport). These are first-paint fallbacks — the real + values are written by ResizeObservers on the actual elements + in +layout.svelte and the reader, so they reflect rendered + size and survive font / zoom / wrap changes. */ --app-header-h: 60px; + --reader-nav-h: 56px; --reader-bar-h: 56px; --z-dropdown: 10; diff --git a/frontend/src/routes/+layout.svelte b/frontend/src/routes/+layout.svelte index dba595e..9a9a399 100644 --- a/frontend/src/routes/+layout.svelte +++ b/frontend/src/routes/+layout.svelte @@ -226,9 +226,9 @@ main { padding: var(--space-4); /* Reserve room for the fixed header so its presence doesn't - overlap content. The min-height is a fallback that matches - the header at typical viewport sizes (60–72px); resize - observers would be more accurate but the gap is forgiving. */ + overlap content. The header height comes from a runtime + ResizeObserver (see onMount above) so this always tracks + the rendered size. */ padding-top: calc(var(--app-header-h) + var(--space-4)); max-width: 64rem; margin: 0 auto; @@ -236,6 +236,8 @@ } :global(html[data-reader-fullscreen='true']) main { - padding-top: var(--space-4); + /* No top reservation in focus mode — the chapter image runs + edge-to-edge once the header has slid off. */ + padding-top: 0; } diff --git a/frontend/src/routes/manga/[id]/chapter/[n]/+page.svelte b/frontend/src/routes/manga/[id]/chapter/[n]/+page.svelte index 166e7fc..59c23f2 100644 --- a/frontend/src/routes/manga/[id]/chapter/[n]/+page.svelte +++ b/frontend/src/routes/manga/[id]/chapter/[n]/+page.svelte @@ -69,6 +69,31 @@ let index = $state(initialIndex); let continuousPageEls: HTMLImageElement[] = $state([]); let chapterBarEl: HTMLElement | undefined = $state(); + let readerNavEl: HTMLElement | undefined = $state(); + + // Publish the reader nav's actual measured height. Sticky + // positioning had a "settle on scroll" effect: the bar's natural + // position sat 16px below the app header (main's space-4 padding), + // and only docked against the header once the user scrolled + // enough to consume that gap. The fix is to lift the bar out of + // document flow entirely (position: fixed) and reserve space in + // the chapter content via `--reader-nav-h`. + $effect(() => { + if (!readerNavEl) return; + const publish = () => { + document.documentElement.style.setProperty( + '--reader-nav-h', + `${readerNavEl!.offsetHeight}px` + ); + }; + publish(); + const ro = new ResizeObserver(publish); + ro.observe(readerNavEl); + return () => { + ro.disconnect(); + document.documentElement.style.removeProperty('--reader-nav-h'); + }; + }); // Publish the bottom chapter-bar's actual measured height so the // continuous container's `padding-bottom` exactly matches it. Same @@ -389,7 +414,7 @@ {pageTitle} -