Fix epub scroll
This commit is contained in:
+21
-25
@@ -6,19 +6,25 @@
|
|||||||
}
|
}
|
||||||
@if (!isLoading) {
|
@if (!isLoading) {
|
||||||
<div>
|
<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">
|
<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">
|
<div class="progress-info">
|
||||||
<span class="progress-percentage"><span class="progress-label">Progress: </span>{{ progressPercentage }}%</span>
|
<span class="progress-percentage"><span class="progress-label">Progress: </span>{{ progressPercentage }}%</span>
|
||||||
</div>
|
</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">
|
<ng-template pTemplate="header">
|
||||||
<div class="drawer-header">
|
<div class="drawer-header">
|
||||||
<span class="drawer-title">Table of Contents</span>
|
<span class="drawer-title">Table of Contents</span>
|
||||||
</div>
|
</div>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
|
||||||
<p-tabs value="0">
|
<p-tabs value="0">
|
||||||
<p-tablist>
|
<p-tablist>
|
||||||
<p-tab value="0">
|
<p-tab value="0">
|
||||||
@@ -60,7 +66,8 @@
|
|||||||
type="text"
|
type="text"
|
||||||
[(ngModel)]="filterText"
|
[(ngModel)]="filterText"
|
||||||
placeholder="Search bookmarks..."
|
placeholder="Search bookmarks..."
|
||||||
class="w-full p-inputtext-sm">
|
class="w-full p-inputtext-sm"
|
||||||
|
(click)="$event.stopPropagation()">
|
||||||
</p-iconfield>
|
</p-iconfield>
|
||||||
</div>
|
</div>
|
||||||
@if (filteredBookmarks.length === 0) {
|
@if (filteredBookmarks.length === 0) {
|
||||||
@@ -108,11 +115,9 @@
|
|||||||
</p-tabs>
|
</p-tabs>
|
||||||
</p-drawer>
|
</p-drawer>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="header-center">
|
<div class="header-center">
|
||||||
<p class="text font-medium">{{ currentChapter }}</p>
|
<p class="text font-medium">{{ currentChapter }}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="header-right">
|
<div class="header-right">
|
||||||
<div class="flex gap-4">
|
<div class="flex gap-4">
|
||||||
@if (!locationsReady) {
|
@if (!locationsReady) {
|
||||||
@@ -123,21 +128,19 @@
|
|||||||
<p-button
|
<p-button
|
||||||
size="small"
|
size="small"
|
||||||
[icon]="isBookmarked ? 'pi pi-bookmark-fill' : 'pi pi-bookmark'"
|
[icon]="isBookmarked ? 'pi pi-bookmark-fill' : 'pi pi-bookmark'"
|
||||||
(click)="addBookmark()"
|
(click)="addBookmark(); $event.stopPropagation()"
|
||||||
severity="secondary"
|
severity="secondary"
|
||||||
[disabled]="!currentCfi || isAddingBookmark">
|
[disabled]="!currentCfi || isAddingBookmark">
|
||||||
</p-button>
|
</p-button>
|
||||||
<div>
|
<div>
|
||||||
<p-button size="small" class="settings-toggle-button" (click)="toggleSettingsDrawer()" icon="pi pi-cog" severity="secondary"></p-button>
|
<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' }">
|
<p-drawer [(visible)]="isSettingsDrawerVisible" [modal]="false" [position]="'right'" [style]="{ width: '340px' }" (click)="$event.stopPropagation()">
|
||||||
<ng-template pTemplate="header">
|
<ng-template pTemplate="header">
|
||||||
<div class="drawer-header">
|
<div class="drawer-header">
|
||||||
<span class="drawer-title">Reader Settings</span>
|
<span class="drawer-title">Reader Settings</span>
|
||||||
</div>
|
</div>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
|
||||||
<div class="settings-container">
|
<div class="settings-container">
|
||||||
|
|
||||||
<div class="settings-card">
|
<div class="settings-card">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<i class="pi pi-text-height"></i>
|
<i class="pi pi-text-height"></i>
|
||||||
@@ -156,7 +159,6 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="setting-row">
|
<div class="setting-row">
|
||||||
<label for="font-type">Font Family</label>
|
<label for="font-type">Font Family</label>
|
||||||
<p-select
|
<p-select
|
||||||
@@ -169,7 +171,6 @@
|
|||||||
placeholder="Select font">
|
placeholder="Select font">
|
||||||
</p-select>
|
</p-select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="setting-row">
|
<div class="setting-row">
|
||||||
<label>Line Height</label>
|
<label>Line Height</label>
|
||||||
<div class="slider-container">
|
<div class="slider-container">
|
||||||
@@ -184,7 +185,6 @@
|
|||||||
</p-slider>
|
</p-slider>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="setting-row">
|
<div class="setting-row">
|
||||||
<label>Letter Spacing</label>
|
<label>Letter Spacing</label>
|
||||||
<div class="slider-container">
|
<div class="slider-container">
|
||||||
@@ -201,7 +201,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="settings-card">
|
<div class="settings-card">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<i class="pi pi-palette"></i>
|
<i class="pi pi-palette"></i>
|
||||||
@@ -230,7 +229,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="settings-card">
|
<div class="settings-card">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<i class="pi pi-file"></i>
|
<i class="pi pi-file"></i>
|
||||||
@@ -256,7 +254,6 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if (selectedFlow === 'paginated' && !isMobileDevice()) {
|
@if (selectedFlow === 'paginated' && !isMobileDevice()) {
|
||||||
<div class="setting-row">
|
<div class="setting-row">
|
||||||
<label>Page Spread</label>
|
<label>Page Spread</label>
|
||||||
@@ -280,14 +277,13 @@
|
|||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</p-drawer>
|
</p-drawer>
|
||||||
</div>
|
</div>
|
||||||
<p-button
|
<p-button
|
||||||
size="small"
|
size="small"
|
||||||
icon="pi pi-times"
|
icon="pi pi-times"
|
||||||
(click)="closeReader()"
|
(click)="closeReader(); $event.stopPropagation()"
|
||||||
severity="secondary"
|
severity="secondary"
|
||||||
pTooltip="Close Reader"
|
pTooltip="Close Reader"
|
||||||
tooltipPosition="bottom">
|
tooltipPosition="bottom">
|
||||||
@@ -295,7 +291,11 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</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') {
|
@if (selectedFlow !== 'scrolled') {
|
||||||
<button class="epub-controls-left" [class.visible]="showControls" [class.dark-theme]="selectedTheme === 'black' || selectedTheme === 'grey'" (click)="prevPage(); onBookTouch()">←</button>
|
<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>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Bookmark Edit Dialog Component -->
|
|
||||||
<app-bookmark-edit-dialog
|
<app-bookmark-edit-dialog
|
||||||
[(visible)]="showEditBookmarkDialog"
|
[(visible)]="showEditBookmarkDialog"
|
||||||
[bookmark]="editingBookmark"
|
[bookmark]="editingBookmark"
|
||||||
@@ -314,8 +312,6 @@
|
|||||||
(save)="onBookmarkSave($event)"
|
(save)="onBookmarkSave($event)"
|
||||||
(cancelEdit)="onBookmarkCancel()">
|
(cancelEdit)="onBookmarkCancel()">
|
||||||
</app-bookmark-edit-dialog>
|
</app-bookmark-edit-dialog>
|
||||||
|
|
||||||
<!-- Bookmark View Dialog Component -->
|
|
||||||
<app-bookmark-view-dialog
|
<app-bookmark-view-dialog
|
||||||
[(visible)]="viewDialogVisible"
|
[(visible)]="viewDialogVisible"
|
||||||
[bookmark]="selectedBookmark">
|
[bookmark]="selectedBookmark">
|
||||||
|
|||||||
+21
-10
@@ -17,9 +17,11 @@
|
|||||||
transition: transform 0.3s ease;
|
transition: transform 0.3s ease;
|
||||||
min-height: 3rem;
|
min-height: 3rem;
|
||||||
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
|
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
|
||||||
|
pointer-events: auto;
|
||||||
|
|
||||||
&.hidden {
|
&.hidden {
|
||||||
transform: translateY(-100%);
|
transform: translateY(-100%);
|
||||||
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,8 +96,8 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
height: 100dvh;
|
height: 100dvh;
|
||||||
overflow: hidden;
|
|
||||||
position: relative;
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.spinner-wrapper {
|
.spinner-wrapper {
|
||||||
@@ -112,15 +114,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
#epubContainer {
|
#epubContainer {
|
||||||
height: 100%;
|
flex: 1;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
position: relative;
|
||||||
|
overflow: auto;
|
||||||
|
pointer-events: auto;
|
||||||
|
|
||||||
|
&.paginated-mode {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
position: absolute;
|
}
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
bottom: 0;
|
|
||||||
z-index: 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.menu-toggle-button,
|
.menu-toggle-button,
|
||||||
@@ -377,8 +379,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.empty-state {
|
.empty-state {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -786,3 +786,14 @@
|
|||||||
opacity: 0.5;
|
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;
|
||||||
|
}
|
||||||
|
|||||||
+32
-17
@@ -449,11 +449,9 @@ export class EpubReaderComponent implements OnInit, OnDestroy {
|
|||||||
this.headerShownByMobileTouch = false;
|
this.headerShownByMobileTouch = false;
|
||||||
this.clearHeaderTimeout();
|
this.clearHeaderTimeout();
|
||||||
} else {
|
} else {
|
||||||
if (!this.isMobileDevice()) {
|
|
||||||
this.startHeaderAutoHide();
|
this.startHeaderAutoHide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
toggleSettingsDrawer(): void {
|
toggleSettingsDrawer(): void {
|
||||||
this.isSettingsDrawerVisible = !this.isSettingsDrawerVisible;
|
this.isSettingsDrawerVisible = !this.isSettingsDrawerVisible;
|
||||||
@@ -462,11 +460,9 @@ export class EpubReaderComponent implements OnInit, OnDestroy {
|
|||||||
this.headerShownByMobileTouch = false;
|
this.headerShownByMobileTouch = false;
|
||||||
this.clearHeaderTimeout();
|
this.clearHeaderTimeout();
|
||||||
} else {
|
} else {
|
||||||
if (!this.isMobileDevice()) {
|
|
||||||
this.startHeaderAutoHide();
|
this.startHeaderAutoHide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private trackProgress(): void {
|
private trackProgress(): void {
|
||||||
if (!this.book || !this.rendition) return;
|
if (!this.book || !this.rendition) return;
|
||||||
@@ -554,13 +550,6 @@ export class EpubReaderComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onBookClick(event: MouseEvent): void {
|
onBookClick(event: MouseEvent): void {
|
||||||
if (this.isDrawerVisible || this.isSettingsDrawerVisible) {
|
|
||||||
this.isDrawerVisible = false;
|
|
||||||
this.isSettingsDrawerVisible = false;
|
|
||||||
this.startHeaderAutoHide();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const clickY = event.clientY;
|
const clickY = event.clientY;
|
||||||
const screenHeight = window.innerHeight;
|
const screenHeight = window.innerHeight;
|
||||||
|
|
||||||
@@ -572,6 +561,7 @@ export class EpubReaderComponent implements OnInit, OnDestroy {
|
|||||||
this.showHeader = true;
|
this.showHeader = true;
|
||||||
this.headerShownByMobileTouch = true;
|
this.headerShownByMobileTouch = true;
|
||||||
this.clearHeaderTimeout();
|
this.clearHeaderTimeout();
|
||||||
|
this.startHeaderAutoHide();
|
||||||
} else if (isBottomClick && this.showHeader && this.headerShownByMobileTouch) {
|
} else if (isBottomClick && this.showHeader && this.headerShownByMobileTouch) {
|
||||||
this.showHeader = false;
|
this.showHeader = false;
|
||||||
this.headerShownByMobileTouch = 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 {
|
onBookMouseMove(event: MouseEvent): void {
|
||||||
if (this.isDrawerVisible || this.isSettingsDrawerVisible || this.isMobileDevice()) {
|
if (this.isDrawerVisible || this.isSettingsDrawerVisible || this.isMobileDevice()) {
|
||||||
return;
|
return;
|
||||||
@@ -608,35 +618,40 @@ export class EpubReaderComponent implements OnInit, OnDestroy {
|
|||||||
onBookTouch(): void {
|
onBookTouch(): void {
|
||||||
if (this.isMobileDevice()) {
|
if (this.isMobileDevice()) {
|
||||||
this.showControls = true;
|
this.showControls = true;
|
||||||
|
this.showHeader = true;
|
||||||
|
this.headerShownByMobileTouch = false;
|
||||||
|
this.clearHeaderTimeout();
|
||||||
|
|
||||||
if (this.hideControlsTimeout) {
|
if (this.hideControlsTimeout) {
|
||||||
window.clearTimeout(this.hideControlsTimeout);
|
window.clearTimeout(this.hideControlsTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.hideControlsTimeout = window.setTimeout(() => {
|
this.hideControlsTimeout = window.setTimeout(() => {
|
||||||
this.ngZone.run(() => {
|
this.ngZone.run(() => {
|
||||||
this.showControls = false;
|
this.showControls = false;
|
||||||
|
if (!this.isDrawerVisible && !this.isSettingsDrawerVisible) {
|
||||||
|
this.showHeader = false;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private startHeaderAutoHide(): void {
|
startHeaderAutoHide(): void {
|
||||||
this.clearHeaderTimeout();
|
this.clearHeaderTimeout();
|
||||||
|
|
||||||
if (this.isDrawerVisible || this.isSettingsDrawerVisible || this.isMouseInTopRegion) {
|
if (this.isDrawerVisible || this.isSettingsDrawerVisible || this.isMouseInTopRegion) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isMobileDevice() && this.headerShownByMobileTouch) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.hideHeaderTimeout = window.setTimeout(() => {
|
this.hideHeaderTimeout = window.setTimeout(() => {
|
||||||
this.ngZone.run(() => {
|
this.ngZone.run(() => {
|
||||||
if (!this.isDrawerVisible && !this.isSettingsDrawerVisible && !this.isMouseInTopRegion) {
|
if (!this.isDrawerVisible && !this.isSettingsDrawerVisible && !this.isMouseInTopRegion) {
|
||||||
this.showHeader = false;
|
this.showHeader = false;
|
||||||
|
this.headerShownByMobileTouch = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, 1000);
|
}, this.isMobileDevice() ? 2000 : 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
private clearHeaderTimeout(): void {
|
private clearHeaderTimeout(): void {
|
||||||
|
|||||||
Reference in New Issue
Block a user