Revert "Remove pdf sidebar for good"

This reverts commit 95913b591c.
This commit is contained in:
aditya.chandel
2025-02-18 07:55:58 -07:00
parent 95913b591c
commit 0ba78430b8
6 changed files with 25 additions and 6 deletions
@@ -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';
}
}