@@ -36,7 +36,10 @@
|
|||||||
<div class="slideshow-progress" [class.above-footer]="isFooterVisible" [style.animation-duration.ms]="slideshowInterval"></div>
|
<div class="slideshow-progress" [class.above-footer]="isFooterVisible" [style.animation-duration.ms]="slideshowInterval"></div>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<div #magnifierLens class="magnifier-lens"></div>
|
||||||
|
|
||||||
<div class="image-container"
|
<div class="image-container"
|
||||||
|
[class.magnifier-active]="isMagnifierActive"
|
||||||
[class.two-page-view]="isTwoPageView && scrollMode === CbxScrollMode.PAGINATED"
|
[class.two-page-view]="isTwoPageView && scrollMode === CbxScrollMode.PAGINATED"
|
||||||
[class.infinite-scroll]="scrollMode === CbxScrollMode.INFINITE"
|
[class.infinite-scroll]="scrollMode === CbxScrollMode.INFINITE"
|
||||||
[class.long-strip]="scrollMode === CbxScrollMode.LONG_STRIP"
|
[class.long-strip]="scrollMode === CbxScrollMode.LONG_STRIP"
|
||||||
|
|||||||
@@ -50,6 +50,19 @@
|
|||||||
to { width: 100%; }
|
to { width: 100%; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.magnifier-lens {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
display: none;
|
||||||
|
border-radius: 50%;
|
||||||
|
border: 3px solid rgba(255, 255, 255, 0.8);
|
||||||
|
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3), 0 8px 32px rgba(0, 0, 0, 0.5);
|
||||||
|
pointer-events: none;
|
||||||
|
z-index: 1000;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
}
|
||||||
|
|
||||||
.bookmark-indicator {
|
.bookmark-indicator {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
@@ -95,6 +108,10 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.magnifier-active {
|
||||||
|
cursor: none;
|
||||||
|
}
|
||||||
|
|
||||||
&.bg-black {
|
&.bg-black {
|
||||||
background: #000000;
|
background: #000000;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import {Component, HostListener, inject, OnDestroy, OnInit} from '@angular/core';
|
import {Component, ElementRef, HostListener, inject, OnDestroy, OnInit, ViewChild} from '@angular/core';
|
||||||
import {ActivatedRoute, Router} from '@angular/router';
|
import {ActivatedRoute, Router} from '@angular/router';
|
||||||
import {CommonModule} from '@angular/common';
|
import {CommonModule} from '@angular/common';
|
||||||
import {forkJoin, Subject} from 'rxjs';
|
import {forkJoin, Subject} from 'rxjs';
|
||||||
@@ -117,6 +117,12 @@ export class CbxReaderComponent implements OnInit, OnDestroy {
|
|||||||
// Shortcuts help dialog
|
// Shortcuts help dialog
|
||||||
showShortcutsHelp = false;
|
showShortcutsHelp = false;
|
||||||
|
|
||||||
|
// Magnifier
|
||||||
|
isMagnifierActive = false;
|
||||||
|
@ViewChild('magnifierLens', {static: true}) private magnifierLensRef!: ElementRef<HTMLDivElement>;
|
||||||
|
private static readonly MAGNIFIER_SIZE = 200;
|
||||||
|
private static readonly MAGNIFIER_ZOOM = 3;
|
||||||
|
|
||||||
// Double page detection
|
// Double page detection
|
||||||
private pageDimensionsCache = new Map<number, {width: number, height: number}>();
|
private pageDimensionsCache = new Map<number, {width: number, height: number}>();
|
||||||
|
|
||||||
@@ -302,6 +308,16 @@ export class CbxReaderComponent implements OnInit, OnDestroy {
|
|||||||
this.toggleSlideshow();
|
this.toggleSlideshow();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.headerService.toggleMagnifier$
|
||||||
|
.pipe(takeUntil(this.destroy$))
|
||||||
|
.subscribe(() => {
|
||||||
|
this.isMagnifierActive = !this.isMagnifierActive;
|
||||||
|
if (!this.isMagnifierActive) {
|
||||||
|
this.hideMagnifier();
|
||||||
|
}
|
||||||
|
this.headerService.updateState({isMagnifierActive: this.isMagnifierActive});
|
||||||
|
});
|
||||||
|
|
||||||
this.headerService.showShortcutsHelp$
|
this.headerService.showShortcutsHelp$
|
||||||
.pipe(takeUntil(this.destroy$))
|
.pipe(takeUntil(this.destroy$))
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
@@ -945,12 +961,25 @@ export class CbxReaderComponent implements OnInit, OnDestroy {
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
this.toggleSlideshow();
|
this.toggleSlideshow();
|
||||||
break;
|
break;
|
||||||
|
case 'm':
|
||||||
|
case 'M':
|
||||||
|
event.preventDefault();
|
||||||
|
this.isMagnifierActive = !this.isMagnifierActive;
|
||||||
|
if (!this.isMagnifierActive) {
|
||||||
|
this.hideMagnifier();
|
||||||
|
}
|
||||||
|
this.headerService.updateState({isMagnifierActive: this.isMagnifierActive});
|
||||||
|
break;
|
||||||
case '?':
|
case '?':
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
this.showShortcutsHelp = true;
|
this.showShortcutsHelp = true;
|
||||||
break;
|
break;
|
||||||
case 'Escape':
|
case 'Escape':
|
||||||
if (this.showShortcutsHelp) {
|
if (this.isMagnifierActive) {
|
||||||
|
this.isMagnifierActive = false;
|
||||||
|
this.hideMagnifier();
|
||||||
|
this.headerService.updateState({isMagnifierActive: false});
|
||||||
|
} else if (this.showShortcutsHelp) {
|
||||||
this.showShortcutsHelp = false;
|
this.showShortcutsHelp = false;
|
||||||
} else if (this.showNoteDialog) {
|
} else if (this.showNoteDialog) {
|
||||||
this.showNoteDialog = false;
|
this.showNoteDialog = false;
|
||||||
@@ -989,11 +1018,17 @@ export class CbxReaderComponent implements OnInit, OnDestroy {
|
|||||||
@HostListener('document:mousemove', ['$event'])
|
@HostListener('document:mousemove', ['$event'])
|
||||||
onMouseMove(event: MouseEvent): void {
|
onMouseMove(event: MouseEvent): void {
|
||||||
this.visibilityManager.handleMouseMove(event.clientY);
|
this.visibilityManager.handleMouseMove(event.clientY);
|
||||||
|
if (this.isMagnifierActive) {
|
||||||
|
this.updateMagnifier(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@HostListener('document:mouseleave', ['$event'])
|
@HostListener('document:mouseleave', ['$event'])
|
||||||
onMouseLeave(event: MouseEvent): void {
|
onMouseLeave(event: MouseEvent): void {
|
||||||
this.visibilityManager.handleMouseLeave();
|
this.visibilityManager.handleMouseLeave();
|
||||||
|
if (this.isMagnifierActive) {
|
||||||
|
this.hideMagnifier();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleSwipeGesture() {
|
private handleSwipeGesture() {
|
||||||
@@ -1224,6 +1259,60 @@ export class CbxReaderComponent implements OnInit, OnDestroy {
|
|||||||
return this.isTwoPageView && this.isSpreadPage(pageIndex);
|
return this.isTwoPageView && this.isSpreadPage(pageIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private updateMagnifier(event: MouseEvent): void {
|
||||||
|
const el = this.magnifierLensRef?.nativeElement;
|
||||||
|
if (!el) return;
|
||||||
|
|
||||||
|
const lensSize = CbxReaderComponent.MAGNIFIER_SIZE;
|
||||||
|
const zoom = CbxReaderComponent.MAGNIFIER_ZOOM;
|
||||||
|
|
||||||
|
const target = document.elementFromPoint(event.clientX, event.clientY);
|
||||||
|
if (!(target instanceof HTMLImageElement) || !target.classList.contains('page-image')) {
|
||||||
|
el.style.display = 'none';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!target.naturalWidth || !target.naturalHeight) {
|
||||||
|
el.style.display = 'none';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const imgRect = target.getBoundingClientRect();
|
||||||
|
const scale = Math.min(imgRect.width / target.naturalWidth, imgRect.height / target.naturalHeight);
|
||||||
|
const renderedWidth = target.naturalWidth * scale;
|
||||||
|
const renderedHeight = target.naturalHeight * scale;
|
||||||
|
const imgOffsetX = (imgRect.width - renderedWidth) / 2;
|
||||||
|
const imgOffsetY = (imgRect.height - renderedHeight) / 2;
|
||||||
|
|
||||||
|
const relX = (event.clientX - imgRect.left - imgOffsetX) / renderedWidth;
|
||||||
|
const relY = (event.clientY - imgRect.top - imgOffsetY) / renderedHeight;
|
||||||
|
|
||||||
|
if (relX < 0 || relX > 1 || relY < 0 || relY > 1) {
|
||||||
|
el.style.display = 'none';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const bgWidth = renderedWidth * zoom;
|
||||||
|
const bgHeight = renderedHeight * zoom;
|
||||||
|
const bgPosX = -(relX * bgWidth - lensSize / 2);
|
||||||
|
const bgPosY = -(relY * bgHeight - lensSize / 2);
|
||||||
|
|
||||||
|
el.style.display = 'block';
|
||||||
|
el.style.width = `${lensSize}px`;
|
||||||
|
el.style.height = `${lensSize}px`;
|
||||||
|
el.style.transform = `translate(${event.clientX - lensSize / 2}px, ${event.clientY - lensSize / 2}px)`;
|
||||||
|
el.style.backgroundImage = `url('${target.src}')`;
|
||||||
|
el.style.backgroundSize = `${bgWidth}px ${bgHeight}px`;
|
||||||
|
el.style.backgroundPosition = `${bgPosX}px ${bgPosY}px`;
|
||||||
|
}
|
||||||
|
|
||||||
|
private hideMagnifier(): void {
|
||||||
|
const el = this.magnifierLensRef?.nativeElement;
|
||||||
|
if (el) {
|
||||||
|
el.style.display = 'none';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Shortcuts help dialog
|
// Shortcuts help dialog
|
||||||
onShortcutsHelpClose(): void {
|
onShortcutsHelpClose(): void {
|
||||||
this.showShortcutsHelp = false;
|
this.showShortcutsHelp = false;
|
||||||
|
|||||||
+2
-1
@@ -46,7 +46,8 @@ export class CbxShortcutsHelpComponent {
|
|||||||
{keys: ['F'], description: this.t.translate('readerCbx.shortcutsHelp.toggleFullscreen')},
|
{keys: ['F'], description: this.t.translate('readerCbx.shortcutsHelp.toggleFullscreen')},
|
||||||
{keys: ['D'], description: this.t.translate('readerCbx.shortcutsHelp.toggleReadingDirection')},
|
{keys: ['D'], description: this.t.translate('readerCbx.shortcutsHelp.toggleReadingDirection')},
|
||||||
{keys: ['Escape'], description: this.t.translate('readerCbx.shortcutsHelp.exitFullscreenCloseDialogs')},
|
{keys: ['Escape'], description: this.t.translate('readerCbx.shortcutsHelp.exitFullscreenCloseDialogs')},
|
||||||
{keys: ['Double-click'], description: this.t.translate('readerCbx.shortcutsHelp.toggleZoom'), mobileGesture: this.t.translate('readerCbx.shortcutsHelp.doubleTap')}
|
{keys: ['Double-click'], description: this.t.translate('readerCbx.shortcutsHelp.toggleZoom'), mobileGesture: this.t.translate('readerCbx.shortcutsHelp.doubleTap')},
|
||||||
|
{keys: ['M'], description: this.t.translate('readerCbx.shortcutsHelp.toggleMagnifier')}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
+3
@@ -15,6 +15,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<span class="book-title">{{ bookTitle }}</span>
|
<span class="book-title">{{ bookTitle }}</span>
|
||||||
<div class="header-right">
|
<div class="header-right">
|
||||||
|
<button class="icon-btn desktop-only" (click)="onToggleMagnifier()" [title]="state.isMagnifierActive ? ('readerCbx.header.disableMagnifier' | transloco) : ('readerCbx.header.enableMagnifier' | transloco)" [class.active]="state.isMagnifierActive">
|
||||||
|
<app-reader-icon name="magnifier" [size]="20" />
|
||||||
|
</button>
|
||||||
<button class="icon-btn desktop-only" (click)="onToggleSlideshow()" [title]="state.isSlideshowActive ? ('readerCbx.header.stopSlideshow' | transloco) : ('readerCbx.header.startSlideshow' | transloco)" [class.active]="state.isSlideshowActive">
|
<button class="icon-btn desktop-only" (click)="onToggleSlideshow()" [title]="state.isSlideshowActive ? ('readerCbx.header.stopSlideshow' | transloco) : ('readerCbx.header.startSlideshow' | transloco)" [class.active]="state.isSlideshowActive">
|
||||||
<app-reader-icon [name]="state.isSlideshowActive ? 'pause' : 'play'" [size]="20" />
|
<app-reader-icon [name]="state.isSlideshowActive ? 'pause' : 'play'" [size]="20" />
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
+6
-1
@@ -24,7 +24,8 @@ export class CbxHeaderComponent implements OnInit, OnDestroy {
|
|||||||
overflowOpen = false;
|
overflowOpen = false;
|
||||||
state: CbxHeaderState = {
|
state: CbxHeaderState = {
|
||||||
isFullscreen: false,
|
isFullscreen: false,
|
||||||
isSlideshowActive: false
|
isSlideshowActive: false,
|
||||||
|
isMagnifierActive: false
|
||||||
};
|
};
|
||||||
|
|
||||||
get bookTitle(): string {
|
get bookTitle(): string {
|
||||||
@@ -70,6 +71,10 @@ export class CbxHeaderComponent implements OnInit, OnDestroy {
|
|||||||
this.headerService.toggleSlideshow();
|
this.headerService.toggleSlideshow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onToggleMagnifier(): void {
|
||||||
|
this.headerService.toggleMagnifier();
|
||||||
|
}
|
||||||
|
|
||||||
onShowShortcutsHelp(): void {
|
onShowShortcutsHelp(): void {
|
||||||
this.headerService.showShortcutsHelp();
|
this.headerService.showShortcutsHelp();
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-2
@@ -6,6 +6,7 @@ import {CbxSidebarService} from '../sidebar/cbx-sidebar.service';
|
|||||||
export interface CbxHeaderState {
|
export interface CbxHeaderState {
|
||||||
isFullscreen: boolean;
|
isFullscreen: boolean;
|
||||||
isSlideshowActive: boolean;
|
isSlideshowActive: boolean;
|
||||||
|
isMagnifierActive: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@@ -22,7 +23,8 @@ export class CbxHeaderService {
|
|||||||
|
|
||||||
private _state = new BehaviorSubject<CbxHeaderState>({
|
private _state = new BehaviorSubject<CbxHeaderState>({
|
||||||
isFullscreen: false,
|
isFullscreen: false,
|
||||||
isSlideshowActive: false
|
isSlideshowActive: false,
|
||||||
|
isMagnifierActive: false
|
||||||
});
|
});
|
||||||
state$ = this._state.asObservable();
|
state$ = this._state.asObservable();
|
||||||
|
|
||||||
@@ -41,6 +43,9 @@ export class CbxHeaderService {
|
|||||||
private _toggleSlideshow = new Subject<void>();
|
private _toggleSlideshow = new Subject<void>();
|
||||||
toggleSlideshow$ = this._toggleSlideshow.asObservable();
|
toggleSlideshow$ = this._toggleSlideshow.asObservable();
|
||||||
|
|
||||||
|
private _toggleMagnifier = new Subject<void>();
|
||||||
|
toggleMagnifier$ = this._toggleMagnifier.asObservable();
|
||||||
|
|
||||||
private _showShortcutsHelp = new Subject<void>();
|
private _showShortcutsHelp = new Subject<void>();
|
||||||
showShortcutsHelp$ = this._showShortcutsHelp.asObservable();
|
showShortcutsHelp$ = this._showShortcutsHelp.asObservable();
|
||||||
|
|
||||||
@@ -94,6 +99,10 @@ export class CbxHeaderService {
|
|||||||
this._toggleSlideshow.next();
|
this._toggleSlideshow.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toggleMagnifier(): void {
|
||||||
|
this._toggleMagnifier.next();
|
||||||
|
}
|
||||||
|
|
||||||
showShortcutsHelp(): void {
|
showShortcutsHelp(): void {
|
||||||
this._showShortcutsHelp.next();
|
this._showShortcutsHelp.next();
|
||||||
}
|
}
|
||||||
@@ -104,7 +113,7 @@ export class CbxHeaderService {
|
|||||||
|
|
||||||
reset(): void {
|
reset(): void {
|
||||||
this._forceVisible.next(true);
|
this._forceVisible.next(true);
|
||||||
this._state.next({isFullscreen: false, isSlideshowActive: false});
|
this._state.next({isFullscreen: false, isSlideshowActive: false, isMagnifierActive: false});
|
||||||
this.bookTitle = '';
|
this.bookTitle = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,8 @@ export type ReaderIconName =
|
|||||||
| 'help'
|
| 'help'
|
||||||
| 'long-strip'
|
| 'long-strip'
|
||||||
| 'direction-ltr'
|
| 'direction-ltr'
|
||||||
| 'direction-rtl';
|
| 'direction-rtl'
|
||||||
|
| 'magnifier';
|
||||||
|
|
||||||
interface IconPath {
|
interface IconPath {
|
||||||
d: string;
|
d: string;
|
||||||
@@ -192,6 +193,12 @@ const ICONS: Record<ReaderIconName, IconPath[]> = {
|
|||||||
'direction-rtl': [
|
'direction-rtl': [
|
||||||
{d: 'M19,12 L5,12', type: 'line'},
|
{d: 'M19,12 L5,12', type: 'line'},
|
||||||
{d: 'M9,8 L5,12 L9,16', type: 'polyline'}
|
{d: 'M9,8 L5,12 L9,16', type: 'polyline'}
|
||||||
|
],
|
||||||
|
'magnifier': [
|
||||||
|
{d: 'M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0-14 0', type: 'path'},
|
||||||
|
{d: 'M21 21l-5-5'},
|
||||||
|
{d: 'M7,10 L13,10', type: 'line'},
|
||||||
|
{d: 'M10,7 L10,13', type: 'line'}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
"toggleZoom": "Toggle zoom (fit page / actual size)",
|
"toggleZoom": "Toggle zoom (fit page / actual size)",
|
||||||
"doubleTap": "Double-tap",
|
"doubleTap": "Double-tap",
|
||||||
"toggleSlideshow": "Toggle slideshow / auto-play",
|
"toggleSlideshow": "Toggle slideshow / auto-play",
|
||||||
|
"toggleMagnifier": "Toggle magnifying glass",
|
||||||
"showHelpDialog": "Show this help dialog"
|
"showHelpDialog": "Show this help dialog"
|
||||||
},
|
},
|
||||||
"footer": {
|
"footer": {
|
||||||
@@ -76,6 +77,8 @@
|
|||||||
"exitFullscreenLabel": "Exit Fullscreen",
|
"exitFullscreenLabel": "Exit Fullscreen",
|
||||||
"fullscreenLabel": "Fullscreen",
|
"fullscreenLabel": "Fullscreen",
|
||||||
"keyboardShortcutsLabel": "Keyboard Shortcuts",
|
"keyboardShortcutsLabel": "Keyboard Shortcuts",
|
||||||
|
"enableMagnifier": "Magnifying Glass (M)",
|
||||||
|
"disableMagnifier": "Disable Magnifying Glass (M)",
|
||||||
"settings": "Settings",
|
"settings": "Settings",
|
||||||
"closeReader": "Close Reader"
|
"closeReader": "Close Reader"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
"toggleZoom": "Alternar zoom (ajustar página / tamaño real)",
|
"toggleZoom": "Alternar zoom (ajustar página / tamaño real)",
|
||||||
"doubleTap": "Doble toque",
|
"doubleTap": "Doble toque",
|
||||||
"toggleSlideshow": "Alternar presentación / reproducción automática",
|
"toggleSlideshow": "Alternar presentación / reproducción automática",
|
||||||
|
"toggleMagnifier": "Alternar lupa",
|
||||||
"showHelpDialog": "Mostrar este diálogo de ayuda"
|
"showHelpDialog": "Mostrar este diálogo de ayuda"
|
||||||
},
|
},
|
||||||
"footer": {
|
"footer": {
|
||||||
@@ -76,6 +77,8 @@
|
|||||||
"exitFullscreenLabel": "Salir de pantalla completa",
|
"exitFullscreenLabel": "Salir de pantalla completa",
|
||||||
"fullscreenLabel": "Pantalla completa",
|
"fullscreenLabel": "Pantalla completa",
|
||||||
"keyboardShortcutsLabel": "Atajos de teclado",
|
"keyboardShortcutsLabel": "Atajos de teclado",
|
||||||
|
"enableMagnifier": "Lupa (M)",
|
||||||
|
"disableMagnifier": "Desactivar lupa (M)",
|
||||||
"settings": "Ajustes",
|
"settings": "Ajustes",
|
||||||
"closeReader": "Cerrar lector"
|
"closeReader": "Cerrar lector"
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user