From 3586dd00dd5e0637fa67c96faaa94180fbcb620a Mon Sep 17 00:00:00 2001 From: acx10 Date: Tue, 23 Dec 2025 22:56:49 -0700 Subject: [PATCH] Fix epub scroll --- .../component/epub-reader.component.html | 46 ++++++++-------- .../component/epub-reader.component.scss | 33 ++++++++---- .../component/epub-reader.component.ts | 53 ++++++++++++------- 3 files changed, 77 insertions(+), 55 deletions(-) diff --git a/booklore-ui/src/app/features/readers/epub-reader/component/epub-reader.component.html b/booklore-ui/src/app/features/readers/epub-reader/component/epub-reader.component.html index c6689108a..c6316cacc 100644 --- a/booklore-ui/src/app/features/readers/epub-reader/component/epub-reader.component.html +++ b/booklore-ui/src/app/features/readers/epub-reader/component/epub-reader.component.html @@ -6,19 +6,25 @@ } @if (!isLoading) {
-
+ @if (isDrawerVisible) { +
+ } + @if (isSettingsDrawerVisible) { +
+ } +
+
- +
Progress: {{ progressPercentage }}%
- +
Table of Contents
- @@ -60,7 +66,8 @@ type="text" [(ngModel)]="filterText" placeholder="Search bookmarks..." - class="w-full p-inputtext-sm"> + class="w-full p-inputtext-sm" + (click)="$event.stopPropagation()">
@if (filteredBookmarks.length === 0) { @@ -108,11 +115,9 @@
-

{{ currentChapter }}

-
@if (!locationsReady) { @@ -123,21 +128,19 @@
- - + +
Reader Settings
-
-
@@ -156,7 +159,6 @@
-
-
@@ -184,7 +185,6 @@
-
@@ -201,7 +201,6 @@
-
@@ -230,7 +229,6 @@
-
@@ -256,7 +254,6 @@
- @if (selectedFlow === 'paginated' && !isMobileDevice()) {
@@ -280,14 +277,13 @@ }
-
@@ -295,7 +291,11 @@
-
+
@if (selectedFlow !== 'scrolled') { } @@ -305,8 +305,6 @@ } - - - - diff --git a/booklore-ui/src/app/features/readers/epub-reader/component/epub-reader.component.scss b/booklore-ui/src/app/features/readers/epub-reader/component/epub-reader.component.scss index 05ccfd799..4bb28c2dc 100644 --- a/booklore-ui/src/app/features/readers/epub-reader/component/epub-reader.component.scss +++ b/booklore-ui/src/app/features/readers/epub-reader/component/epub-reader.component.scss @@ -17,9 +17,11 @@ transition: transform 0.3s ease; min-height: 3rem; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3); + pointer-events: auto; &.hidden { transform: translateY(-100%); + pointer-events: none; } } @@ -94,8 +96,8 @@ display: flex; flex-direction: column; height: 100dvh; - overflow: hidden; position: relative; + overflow: hidden; } .spinner-wrapper { @@ -112,15 +114,15 @@ } #epubContainer { - height: 100%; + flex: 1; width: 100%; - overflow: hidden; - position: absolute; - top: 0; - left: 0; - right: 0; - bottom: 0; - z-index: 1; + position: relative; + overflow: auto; + pointer-events: auto; + + &.paginated-mode { + overflow: hidden; + } } .menu-toggle-button, @@ -377,8 +379,6 @@ } } - - .empty-state { display: flex; flex-direction: column; @@ -786,3 +786,14 @@ opacity: 0.5; } } + +.drawer-backdrop { + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: rgba(0, 0, 0, 0.4); + z-index: 999; + cursor: pointer; +} diff --git a/booklore-ui/src/app/features/readers/epub-reader/component/epub-reader.component.ts b/booklore-ui/src/app/features/readers/epub-reader/component/epub-reader.component.ts index 83ae3c3f3..4824c34d9 100644 --- a/booklore-ui/src/app/features/readers/epub-reader/component/epub-reader.component.ts +++ b/booklore-ui/src/app/features/readers/epub-reader/component/epub-reader.component.ts @@ -449,9 +449,7 @@ export class EpubReaderComponent implements OnInit, OnDestroy { this.headerShownByMobileTouch = false; this.clearHeaderTimeout(); } else { - if (!this.isMobileDevice()) { - this.startHeaderAutoHide(); - } + this.startHeaderAutoHide(); } } @@ -462,9 +460,7 @@ export class EpubReaderComponent implements OnInit, OnDestroy { this.headerShownByMobileTouch = false; this.clearHeaderTimeout(); } else { - if (!this.isMobileDevice()) { - this.startHeaderAutoHide(); - } + this.startHeaderAutoHide(); } } @@ -554,13 +550,6 @@ export class EpubReaderComponent implements OnInit, OnDestroy { } onBookClick(event: MouseEvent): void { - if (this.isDrawerVisible || this.isSettingsDrawerVisible) { - this.isDrawerVisible = false; - this.isSettingsDrawerVisible = false; - this.startHeaderAutoHide(); - return; - } - const clickY = event.clientY; const screenHeight = window.innerHeight; @@ -572,6 +561,7 @@ export class EpubReaderComponent implements OnInit, OnDestroy { this.showHeader = true; this.headerShownByMobileTouch = true; this.clearHeaderTimeout(); + this.startHeaderAutoHide(); } else if (isBottomClick && this.showHeader && this.headerShownByMobileTouch) { this.showHeader = false; this.headerShownByMobileTouch = false; @@ -586,6 +576,26 @@ export class EpubReaderComponent implements OnInit, OnDestroy { } } + onHeaderZoneEnter(): void { + if (this.isMobileDevice()) return; + this.isMouseInTopRegion = true; + this.showHeader = true; + this.clearHeaderTimeout(); + } + + onHeaderZoneLeave(): void { + if (this.isMobileDevice()) return; + this.isMouseInTopRegion = false; + this.startHeaderAutoHide(); + } + + onHeaderZoneClick(event: MouseEvent): void { + if (!this.showHeader) { + this.showHeader = true; + this.clearHeaderTimeout(); + } + } + onBookMouseMove(event: MouseEvent): void { if (this.isDrawerVisible || this.isSettingsDrawerVisible || this.isMobileDevice()) { return; @@ -608,35 +618,40 @@ export class EpubReaderComponent implements OnInit, OnDestroy { onBookTouch(): void { if (this.isMobileDevice()) { this.showControls = true; + this.showHeader = true; + this.headerShownByMobileTouch = false; + this.clearHeaderTimeout(); + if (this.hideControlsTimeout) { window.clearTimeout(this.hideControlsTimeout); } + this.hideControlsTimeout = window.setTimeout(() => { this.ngZone.run(() => { this.showControls = false; + if (!this.isDrawerVisible && !this.isSettingsDrawerVisible) { + this.showHeader = false; + } }); }, 2000); } } - private startHeaderAutoHide(): void { + startHeaderAutoHide(): void { this.clearHeaderTimeout(); if (this.isDrawerVisible || this.isSettingsDrawerVisible || this.isMouseInTopRegion) { return; } - if (this.isMobileDevice() && this.headerShownByMobileTouch) { - return; - } - this.hideHeaderTimeout = window.setTimeout(() => { this.ngZone.run(() => { if (!this.isDrawerVisible && !this.isSettingsDrawerVisible && !this.isMouseInTopRegion) { this.showHeader = false; + this.headerShownByMobileTouch = false; } }); - }, 1000); + }, this.isMobileDevice() ? 2000 : 1000); } private clearHeaderTimeout(): void {