@@ -5,11 +5,12 @@
|
||||
[page]="page"
|
||||
[rotation]="rotation"
|
||||
[scrollMode]="scrollMode"
|
||||
[sidebarVisible]="sidebarVisible"
|
||||
[zoom]="zoom"
|
||||
[spread]="spread"
|
||||
[sidebarVisible]="false"
|
||||
(pageChange)="onPageChange($event)"
|
||||
(zoomChange)="onZoomChange($event)"
|
||||
(sidebarVisibleChange)="onSidebarVisibleChange($event)"
|
||||
(pdfLoaded)="onPdfLoaded($event)"
|
||||
(spreadChange)="onSpreadChange($event)">
|
||||
</ngx-extended-pdf-viewer>
|
||||
|
||||
@@ -18,6 +18,7 @@ export class PdfViewerComponent implements OnInit, OnDestroy {
|
||||
rotation: 0 | 90 | 180 | 270 = 0;
|
||||
scrollMode: ScrollModeType = ScrollModeType.page;
|
||||
|
||||
sidebarVisible!: boolean;
|
||||
page!: number;
|
||||
spread!: 'off' | 'even' | 'odd';
|
||||
zoom!: number | string;
|
||||
@@ -78,6 +79,14 @@ export class PdfViewerComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
onSidebarVisibleChange(visible: boolean): void {
|
||||
if (!this.pdfLoaded) return;
|
||||
if (visible !== this.sidebarVisible) {
|
||||
this.sidebarVisible = visible;
|
||||
this.updateViewerSetting();
|
||||
}
|
||||
}
|
||||
|
||||
onSpreadChange(spread: 'off' | 'even' | 'odd'): void {
|
||||
if (!this.pdfLoaded) return;
|
||||
if (spread !== this.spread) {
|
||||
@@ -90,6 +99,7 @@ export class PdfViewerComponent implements OnInit, OnDestroy {
|
||||
if (!this.pdfLoaded) return;
|
||||
const bookSetting: BookSetting = {
|
||||
pdfSettings: {
|
||||
sidebarVisible: this.sidebarVisible,
|
||||
spread: this.spread,
|
||||
zoom: this.zoom,
|
||||
}
|
||||
@@ -113,9 +123,11 @@ export class PdfViewerComponent implements OnInit, OnDestroy {
|
||||
this.updateProgress();
|
||||
if (this.pdfScope === 'global') {
|
||||
this.zoom = this.globalPdfSettings?.zoom || 'page-fit';
|
||||
this.sidebarVisible = this.globalPdfSettings?.sidebar ?? true;
|
||||
this.spread = this.globalPdfSettings?.spread || 'odd';
|
||||
} else {
|
||||
this.zoom = this.individualPdfSettings?.zoom || this.globalPdfSettings?.zoom || 'page-fit';
|
||||
this.sidebarVisible = this.individualPdfSettings?.sidebarVisible ?? this.globalPdfSettings?.sidebar ?? true;
|
||||
this.spread = this.individualPdfSettings?.spread || this.globalPdfSettings?.spread || 'odd';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,6 +72,7 @@ export interface Award {
|
||||
|
||||
export interface PdfViewerSetting {
|
||||
zoom: string | number;
|
||||
sidebarVisible: boolean;
|
||||
spread: 'off' | 'even' | 'odd';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user