feat(reader): fullscreen mode; revert stacked volume; fix manga badges + ghost sidebar
Reader fullscreen: the topbar gains a fullscreen toggle (icon state + f shortcut + help row; f is guarded so Ctrl/Cmd+F stays find-in-page). Enter requests the Fullscreen API with fallbacks (desktop/Android get a true full display; iOS Safari has no page-fullscreen API and falls back to the soft visual mode only). Margins: the foliate paginator's closed shadow root only yields through its observed 'margin' attribute, so fullscreen fits a comfortable ratio (6% of the short side, floored at 48px) and floors it by the measured env insets — Android reports true cutout insets in fullscreen, so portrait phones keep text clear of the camera band; iOS letterboxes are already env-padded chrome. Fixed-layout renderers skip it (fxl/webtoon pack pages edge-to-edge by design). Exits the user makes outside the toggle (Esc, browser UI) sync via fullscreenchange(+webkit) and restore the ordinary 48px margin; a position-keeping re-render follows the ResizeObserver re-entry path. Verified on-device: enter -> true fullscreen + icon swap + camera band clear, exit -> chrome back, margins restored, position kept. Volume: revert the stacked panel — the popup returns to the liked shape (mute button left, horizontal dragger right, dialogue above the strip); one-line flex restore of the pre-89665fb layout. Manga badges: MediaBadgeKind makes the library type authoritative for the comic/manga split — manga volumes ship as fixed_layout scans as often as comic_archive (and manga_type is unreliable across sources: unknown/NULL on real rows), so the old comic_archive+manga mapping left the scan volumes unbadged. Anything in a manga library reads manga; anything in a comics library reads comic. Verified: /dashboard lands 24 title="Manga" cover badges for the Manga library and the sections API reports badge=manga for a fixed_layout item. Ghost sidebar: the >=1024px media block applied body padding-left:var(--sidebar-w) unconditionally, so pages that never render the sidebar (logged-out pages, the audio player, the reader itself) carried a phantom 16rem left margin that pushed content off center on desktop widths. The body:has(.app-sidebar) rule below was already the correct conditional source — it is now the only one. Verified in the built stylesheet: exactly one such rule remains. Infra: main.js ?v=3 stamp bump (reader.ts changed; hashed chunks churn their URLs themselves).
This commit is contained in:
1 parent
89665fb2bc
commit
73ae1789c5
44 files changed
+707
-577
No files matched your search
+115
-1
@@ -421,6 +421,12 @@ document.addEventListener("alpine:init", () => {
|
||||
hideTimer: null as ReturnType<typeof setTimeout> | null,
|
||||
toolsOpen: false,
|
||||
helpOpen: false,
|
||||
// Fullscreen mode — see toggleFullscreen(). Tracks both the real
|
||||
// Fullscreen-API surface (desktop/Android) and the soft visual mode
|
||||
// iOS falls back to (its browser exposes no page-fullscreen API).
|
||||
isFullscreen: false as boolean,
|
||||
softFullscreen: false as boolean,
|
||||
_hadRealFullscreen: false as boolean,
|
||||
pointerFine: true as boolean,
|
||||
fxZoomed: false as boolean,
|
||||
tapZonesEnabled: true as boolean,
|
||||
@@ -1044,6 +1050,7 @@ document.addEventListener("alpine:init", () => {
|
||||
this.refreshBookmarks();
|
||||
this.setupChrome();
|
||||
this.setupTapZones();
|
||||
this.setupFullscreen();
|
||||
},
|
||||
// Chrome visibility: bars overlay the edge-to-edge reading surface.
|
||||
// 'auto-hide' reveals them ONLY from explicit UI intent — cursor in
|
||||
@@ -3293,6 +3300,109 @@ document.addEventListener("alpine:init", () => {
|
||||
toggleHelp() {
|
||||
this.helpOpen = !this.helpOpen;
|
||||
},
|
||||
// Fullscreen: the Fullscreen API on desktop/Android, with iOS's
|
||||
// API-less browser falling back to the soft visual mode only (margins
|
||||
// adopt the fullscreen style while the browser chrome stays). The
|
||||
// reader chrome keeps its own env(safe-area-inset-*) clearances, and
|
||||
// the foliate paginator — whose closed shadow root can only be told
|
||||
// through its observed attributes — gets a comfortable 'margin' with a
|
||||
// safe-area floor, so full-window text never hugs the display edges
|
||||
// nor runs under the camera.
|
||||
toggleFullscreen() {
|
||||
const doc = document as any;
|
||||
const realActive = !!doc.fullscreenElement || !!doc.webkitFullscreenElement;
|
||||
if (realActive || this.softFullscreen) this._exitFullscreenMode();
|
||||
else this._enterFullscreenMode();
|
||||
},
|
||||
_enterFullscreenMode() {
|
||||
this.softFullscreen = true;
|
||||
this.isFullscreen = true;
|
||||
this._applyFullscreenLayout(true);
|
||||
const root = document.documentElement as any;
|
||||
if (typeof root.requestFullscreen === "function") {
|
||||
root
|
||||
.requestFullscreen({ navigationUI: "hide" })
|
||||
.catch(() => { /* denied or interrupted; the visual mode still holds */ });
|
||||
} else if (typeof root.webkitRequestFullscreen === "function") {
|
||||
root.webkitRequestFullscreen();
|
||||
}
|
||||
},
|
||||
_exitFullscreenMode() {
|
||||
this.softFullscreen = false;
|
||||
this.isFullscreen = false;
|
||||
this._applyFullscreenLayout(false);
|
||||
const doc = document as any;
|
||||
if (doc.fullscreenElement && typeof doc.exitFullscreen === "function") {
|
||||
doc.exitFullscreen().catch(() => { /* ignore */ });
|
||||
} else if (
|
||||
doc.webkitFullscreenElement &&
|
||||
typeof doc.webkitExitFullscreen === "function"
|
||||
) {
|
||||
doc.webkitExitFullscreen();
|
||||
}
|
||||
},
|
||||
// Fullscreen text margins: the paginator yields only through its
|
||||
// observed 'margin' attribute (a raw px value for its closed root).
|
||||
// While fullscreen, floor the comfortable ratio by the measured env
|
||||
// insets — Android reports true cutout insets in fullscreen, and iOS
|
||||
// letterboxes are already env-padded chrome, so portrait phones keep
|
||||
// text clear of the camera band. Fixed-layout renderers (fxl,
|
||||
// webtoon) pack pages edge-to-edge by design and never set it.
|
||||
_applyFullscreenLayout(active: boolean) {
|
||||
const renderer = (this.view as any)?.renderer;
|
||||
if (!renderer || this.isFixedLayout) return;
|
||||
if (!active) {
|
||||
renderer.setAttribute("margin", "48px");
|
||||
} else {
|
||||
let insets = 0;
|
||||
// env() is not readable in JS: measure the resolved values off the
|
||||
// chrome, whose padding IS the env inset.
|
||||
for (const [id, edge] of [
|
||||
["reader-topbar", "paddingTop"],
|
||||
["reader-bottombar", "paddingBottom"],
|
||||
] as const) {
|
||||
try {
|
||||
const el = document.getElementById(id);
|
||||
const v = el ? parseFloat(getComputedStyle(el)[edge]) || 0 : 0;
|
||||
if (v > insets) insets = v;
|
||||
} catch {
|
||||
/* keep 0 */
|
||||
}
|
||||
}
|
||||
const comfortable = Math.round(
|
||||
Math.min(window.innerWidth, window.innerHeight) * 0.06,
|
||||
);
|
||||
const margin = Math.round(Math.max(insets, comfortable, 48));
|
||||
renderer.setAttribute("margin", `${margin}px`);
|
||||
}
|
||||
// Margin/gap only take effect on a (re)layout: force one; the anchor
|
||||
// keeps the position (same re-entry path the ResizeObserver uses).
|
||||
if (typeof renderer.render === "function") renderer.render();
|
||||
},
|
||||
// Watch API transitions so exits that happen outside our button
|
||||
// (Esc on desktop, browser UI) restore the ordinary margins too.
|
||||
setupFullscreen() {
|
||||
const doc = document as any;
|
||||
const handler = () => {
|
||||
const realActive =
|
||||
!!doc.fullscreenElement || !!doc.webkitFullscreenElement;
|
||||
if (realActive) {
|
||||
this._hadRealFullscreen = true;
|
||||
// Insets only settle after the fullscreen relayout (Android
|
||||
// switches to true cutout insets): re-apply shortly after entry.
|
||||
setTimeout(() => {
|
||||
if (this.softFullscreen) this._applyFullscreenLayout(true);
|
||||
}, 250);
|
||||
} else if (this._hadRealFullscreen) {
|
||||
this._hadRealFullscreen = false;
|
||||
this.softFullscreen = false;
|
||||
this._applyFullscreenLayout(false);
|
||||
}
|
||||
this.isFullscreen = realActive || this.softFullscreen;
|
||||
};
|
||||
doc.addEventListener("fullscreenchange", handler);
|
||||
doc.addEventListener("webkitfullscreenchange", handler);
|
||||
},
|
||||
// Desktop edge page-turn zones: fine-pointer devices only, and disabled
|
||||
// while a fixed-layout page is zoomed (edge clicks then belong to the
|
||||
// content: panning, text selection, highlight editing).
|
||||
@@ -4159,7 +4269,11 @@ document.addEventListener("alpine:init", () => {
|
||||
if (k === "t") this.toggleTOC();
|
||||
else if (k === "s") this.toggleSettings();
|
||||
else if (k === "b") this.addBookmark();
|
||||
else if (k === "a") {
|
||||
else if (k === "f") {
|
||||
// Ctrl/Cmd+F stays the browser's find-in-page.
|
||||
if (!event.ctrlKey && !event.metaKey && !event.altKey)
|
||||
this.toggleFullscreen();
|
||||
} else if (k === "a") {
|
||||
if (!event.ctrlKey && !event.metaKey && !event.altKey) this.toggleBookmarks();
|
||||
}
|
||||
else if (k === "?") this.toggleHelp();
|
||||
|
||||
Reference in new issue
Block a user