Fix epub scroll
This commit is contained in:
+21
-25
@@ -6,19 +6,25 @@
|
||||
}
|
||||
@if (!isLoading) {
|
||||
<div>
|
||||
<div class="epub-header" [class.hidden]="!showHeader">
|
||||
@if (isDrawerVisible) {
|
||||
<div class="drawer-backdrop" (click)="isDrawerVisible = false; startHeaderAutoHide()"></div>
|
||||
}
|
||||
@if (isSettingsDrawerVisible) {
|
||||
<div class="drawer-backdrop" (click)="isSettingsDrawerVisible = false; startHeaderAutoHide()"></div>
|
||||
}
|
||||
<div style="position: absolute; top: 0; left: 0; right: 0; height: 80px; z-index: 1000; pointer-events: auto;" (mouseenter)="onHeaderZoneEnter()" (mouseleave)="onHeaderZoneLeave()" (click)="onHeaderZoneClick($event)"></div>
|
||||
<div class="epub-header" [class.hidden]="!showHeader" (click)="$event.stopPropagation()">
|
||||
<div class="header-left">
|
||||
<p-button size="small" class="menu-toggle-button" (click)="toggleDrawer()" icon="pi pi-bars" severity="secondary"></p-button>
|
||||
<p-button size="small" class="menu-toggle-button" (click)="toggleDrawer(); $event.stopPropagation()" icon="pi pi-bars" severity="secondary"></p-button>
|
||||
<div class="progress-info">
|
||||
<span class="progress-percentage"><span class="progress-label">Progress: </span>{{ progressPercentage }}%</span>
|
||||
</div>
|
||||
<p-drawer [(visible)]="isDrawerVisible" [modal]="false" [position]="'left'" [style]="{ width: '320px' }">
|
||||
<p-drawer [(visible)]="isDrawerVisible" [modal]="false" [position]="'left'" [style]="{ width: '320px' }" (click)="$event.stopPropagation()">
|
||||
<ng-template pTemplate="header">
|
||||
<div class="drawer-header">
|
||||
<span class="drawer-title">Table of Contents</span>
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
<p-tabs value="0">
|
||||
<p-tablist>
|
||||
<p-tab value="0">
|
||||
@@ -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()">
|
||||
</p-iconfield>
|
||||
</div>
|
||||
@if (filteredBookmarks.length === 0) {
|
||||
@@ -108,11 +115,9 @@
|
||||
</p-tabs>
|
||||
</p-drawer>
|
||||
</div>
|
||||
|
||||
<div class="header-center">
|
||||
<p class="text font-medium">{{ currentChapter }}</p>
|
||||
</div>
|
||||
|
||||
<div class="header-right">
|
||||
<div class="flex gap-4">
|
||||
@if (!locationsReady) {
|
||||
@@ -123,21 +128,19 @@
|
||||
<p-button
|
||||
size="small"
|
||||
[icon]="isBookmarked ? 'pi pi-bookmark-fill' : 'pi pi-bookmark'"
|
||||
(click)="addBookmark()"
|
||||
(click)="addBookmark(); $event.stopPropagation()"
|
||||
severity="secondary"
|
||||
[disabled]="!currentCfi || isAddingBookmark">
|
||||
</p-button>
|
||||
<div>
|
||||
<p-button size="small" class="settings-toggle-button" (click)="toggleSettingsDrawer()" icon="pi pi-cog" severity="secondary"></p-button>
|
||||
<p-drawer [(visible)]="isSettingsDrawerVisible" [modal]="false" [position]="'right'" [style]="{ width: '340px' }">
|
||||
<p-button size="small" class="settings-toggle-button" (click)="toggleSettingsDrawer(); $event.stopPropagation()" icon="pi pi-cog" severity="secondary"></p-button>
|
||||
<p-drawer [(visible)]="isSettingsDrawerVisible" [modal]="false" [position]="'right'" [style]="{ width: '340px' }" (click)="$event.stopPropagation()">
|
||||
<ng-template pTemplate="header">
|
||||
<div class="drawer-header">
|
||||
<span class="drawer-title">Reader Settings</span>
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
<div class="settings-container">
|
||||
|
||||
<div class="settings-card">
|
||||
<div class="card-header">
|
||||
<i class="pi pi-text-height"></i>
|
||||
@@ -156,7 +159,6 @@
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-row">
|
||||
<label for="font-type">Font Family</label>
|
||||
<p-select
|
||||
@@ -169,7 +171,6 @@
|
||||
placeholder="Select font">
|
||||
</p-select>
|
||||
</div>
|
||||
|
||||
<div class="setting-row">
|
||||
<label>Line Height</label>
|
||||
<div class="slider-container">
|
||||
@@ -184,7 +185,6 @@
|
||||
</p-slider>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-row">
|
||||
<label>Letter Spacing</label>
|
||||
<div class="slider-container">
|
||||
@@ -201,7 +201,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="settings-card">
|
||||
<div class="card-header">
|
||||
<i class="pi pi-palette"></i>
|
||||
@@ -230,7 +229,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="settings-card">
|
||||
<div class="card-header">
|
||||
<i class="pi pi-file"></i>
|
||||
@@ -256,7 +254,6 @@
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (selectedFlow === 'paginated' && !isMobileDevice()) {
|
||||
<div class="setting-row">
|
||||
<label>Page Spread</label>
|
||||
@@ -280,14 +277,13 @@
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</p-drawer>
|
||||
</div>
|
||||
<p-button
|
||||
size="small"
|
||||
icon="pi pi-times"
|
||||
(click)="closeReader()"
|
||||
(click)="closeReader(); $event.stopPropagation()"
|
||||
severity="secondary"
|
||||
pTooltip="Close Reader"
|
||||
tooltipPosition="bottom">
|
||||
@@ -295,7 +291,11 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="epubContainer" #epubContainer (click)="onBookClick($event)" (mousemove)="onBookMouseMove($event)"></div>
|
||||
<div id="epubContainer"
|
||||
#epubContainer
|
||||
[class.paginated-mode]="selectedFlow === 'paginated'"
|
||||
(click)="onBookClick($event)"
|
||||
(mousemove)="onBookMouseMove($event)"></div>
|
||||
@if (selectedFlow !== 'scrolled') {
|
||||
<button class="epub-controls-left" [class.visible]="showControls" [class.dark-theme]="selectedTheme === 'black' || selectedTheme === 'grey'" (click)="prevPage(); onBookTouch()">←</button>
|
||||
}
|
||||
@@ -305,8 +305,6 @@
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<!-- Bookmark Edit Dialog Component -->
|
||||
<app-bookmark-edit-dialog
|
||||
[(visible)]="showEditBookmarkDialog"
|
||||
[bookmark]="editingBookmark"
|
||||
@@ -314,8 +312,6 @@
|
||||
(save)="onBookmarkSave($event)"
|
||||
(cancelEdit)="onBookmarkCancel()">
|
||||
</app-bookmark-edit-dialog>
|
||||
|
||||
<!-- Bookmark View Dialog Component -->
|
||||
<app-bookmark-view-dialog
|
||||
[(visible)]="viewDialogVisible"
|
||||
[bookmark]="selectedBookmark">
|
||||
|
||||
+22
-11
@@ -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;
|
||||
}
|
||||
|
||||
+34
-19
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user