Feat: Double-Tap for Reader Bar (#29)

This commit is contained in:
Youwes09
2026-04-16 00:29:46 -05:00
parent 236d6bcf08
commit c0c486a53e
2 changed files with 27 additions and 3 deletions
+21 -1
View File
@@ -182,6 +182,7 @@
const autoNext = $derived(store.settings.autoNextChapter ?? false); const autoNext = $derived(store.settings.autoNextChapter ?? false);
const markOnNext = $derived(store.settings.markReadOnNext ?? true); const markOnNext = $derived(store.settings.markReadOnNext ?? true);
const overlayBars = $derived(store.settings.overlayBars ?? false); const overlayBars = $derived(store.settings.overlayBars ?? false);
const tapToToggleBar = $derived(store.settings.tapToToggleBar ?? false);
const lastPage = $derived(store.pageUrls.length); const lastPage = $derived(store.pageUrls.length);
const effectiveWidth = $derived(containerWidth > 0 ? Math.round(containerWidth * zoom) : undefined); const effectiveWidth = $derived(containerWidth > 0 ? Math.round(containerWidth * zoom) : undefined);
const zoomPct = $derived(Math.round(zoom * 100)); const zoomPct = $derived(Math.round(zoom * 100));
@@ -776,8 +777,19 @@
function showUi() { function showUi() {
uiVisible = true; uiVisible = true;
if (hideTimer) clearTimeout(hideTimer); if (hideTimer) clearTimeout(hideTimer);
if (!tapToToggleBar) {
hideTimer = setTimeout(() => { if (!markerOpen && !winOpen) uiVisible = false; }, 3000); hideTimer = setTimeout(() => { if (!markerOpen && !winOpen) uiVisible = false; }, 3000);
} }
}
function toggleUiVisibility() {
if (uiVisible) {
if (hideTimer) { clearTimeout(hideTimer); hideTimer = null; }
uiVisible = false;
} else {
uiVisible = true;
}
}
$effect(() => { $effect(() => {
if (markerOpen || winOpen) { if (markerOpen || winOpen) {
@@ -786,6 +798,13 @@
} }
}); });
$effect(() => {
if (tapToToggleBar) {
if (hideTimer) { clearTimeout(hideTimer); hideTimer = null; }
uiVisible = true;
}
});
const INSPECT_ZOOM_STEP = 0.15; const INSPECT_ZOOM_STEP = 0.15;
const INSPECT_ZOOM_MAX = 8; const INSPECT_ZOOM_MAX = 8;
@@ -940,7 +959,7 @@
}); });
</script> </script>
<div class="root" class:overlay-bars={overlayBars} role="presentation" onmousemove={(e) => { if (e.clientY < 60 || window.innerHeight - e.clientY < 60) showUi(); }}> <div class="root" class:overlay-bars={overlayBars} role="presentation" onmousemove={(e) => { if (!tapToToggleBar && (e.clientY < 60 || window.innerHeight - e.clientY < 60)) showUi(); }}>
<div class="topbar" class:hidden={!uiVisible}> <div class="topbar" class:hidden={!uiVisible}>
@@ -1158,6 +1177,7 @@
role="presentation" role="presentation"
tabindex="-1" tabindex="-1"
onclick={handleTap} onclick={handleTap}
ondblclick={(e) => { if (tapToToggleBar) { const x = e.clientX / window.innerWidth; if (x >= 0.3 && x <= 0.7) toggleUiVisibility(); } }}
onmousedown={onInspectMouseDown} onmousedown={onInspectMouseDown}
onwheel={(e) => { if (e.ctrlKey || style !== "longstrip") e.preventDefault(); }} onwheel={(e) => { if (e.ctrlKey || style !== "longstrip") e.preventDefault(); }}
onkeydown={(e) => { if (e.key === " " && style === "longstrip") { e.preventDefault(); containerEl?.scrollBy({ top: containerEl.clientHeight * 0.85, behavior: "smooth" }); } }} onkeydown={(e) => { if (e.key === " " && style === "longstrip") { e.preventDefault(); containerEl?.scrollBy({ top: containerEl.clientHeight * 0.85, behavior: "smooth" }); } }}
+4
View File
@@ -1320,6 +1320,10 @@
<div class="toggle-info"><span class="toggle-label">Overlay bars</span><span class="toggle-desc">Floats the nav and chapter bars over the page instead of pushing content</span></div> <div class="toggle-info"><span class="toggle-label">Overlay bars</span><span class="toggle-desc">Floats the nav and chapter bars over the page instead of pushing content</span></div>
<button role="switch" aria-checked={store.settings.overlayBars ?? false} aria-label="Overlay bars" class="toggle" class:on={store.settings.overlayBars ?? false} onclick={() => updateSettings({ overlayBars: !(store.settings.overlayBars ?? false) })}><span class="toggle-thumb"></span></button> <button role="switch" aria-checked={store.settings.overlayBars ?? false} aria-label="Overlay bars" class="toggle" class:on={store.settings.overlayBars ?? false} onclick={() => updateSettings({ overlayBars: !(store.settings.overlayBars ?? false) })}><span class="toggle-thumb"></span></button>
</label> </label>
<label class="toggle-row">
<div class="toggle-info"><span class="toggle-label">Tap to toggle bar</span><span class="toggle-desc">Double-tap the center of the reader to show or hide the bars ideal for touchscreens</span></div>
<button role="switch" aria-checked={store.settings.tapToToggleBar ?? false} aria-label="Tap to toggle bar" class="toggle" class:on={store.settings.tapToToggleBar ?? false} onclick={() => updateSettings({ tapToToggleBar: !(store.settings.tapToToggleBar ?? false) })}><span class="toggle-thumb"></span></button>
</label>
</div> </div>
<div class="section"> <div class="section">
<p class="section-title">Fit &amp; Zoom</p> <p class="section-title">Fit &amp; Zoom</p>