Add (basic) support for Spread modes in PresentationMode (issue 14749)

After recent changes, adding *basic* Spread mode support in PresentationMode has now become reasonably straightforward.

However, documents with *varying* page sizes are non-trivial to handle and would require re-writing (or at least re-factoring) a bunch of the zooming-code.
Hence this PR *purposely* only allow Spread modes to be used, in PresentationMode, for documents where all pages have exactly the same size. While this obviously isn't a fully complete solution, it will however cover the vast majority of all documents and should hopefully be deemed good enough for now.
This commit is contained in:
Jonas Jenwald 2022-05-05 11:15:45 +02:00
parent 54410d5e41
commit 4fffab4ad3

View File

@ -78,9 +78,20 @@ class PDFPresentationMode {
pageNumber: pdfViewer.currentPageNumber,
scaleValue: pdfViewer.currentScaleValue,
scrollMode: pdfViewer.scrollMode,
spreadMode: pdfViewer.spreadMode,
spreadMode: null,
};
if (
pdfViewer.spreadMode !== SpreadMode.NONE &&
!(pdfViewer.pageViewsReady && pdfViewer.hasEqualPageSizes)
) {
console.warn(
"Ignoring Spread modes when entering PresentationMode, " +
"since the document may contain varying page sizes."
);
this.#args.spreadMode = pdfViewer.spreadMode;
}
try {
await promise;
return true;
@ -151,7 +162,9 @@ class PDFPresentationMode {
// Presentation Mode, by waiting until fullscreen mode in enabled.
setTimeout(() => {
this.pdfViewer.scrollMode = ScrollMode.PAGE;
if (this.#args.spreadMode !== null) {
this.pdfViewer.spreadMode = SpreadMode.NONE;
}
this.pdfViewer.currentPageNumber = this.#args.pageNumber;
this.pdfViewer.currentScaleValue = "page-fit";
}, 0);
@ -177,7 +190,9 @@ class PDFPresentationMode {
this.#notifyStateChange(PresentationModeState.NORMAL);
this.pdfViewer.scrollMode = this.#args.scrollMode;
if (this.#args.spreadMode !== null) {
this.pdfViewer.spreadMode = this.#args.spreadMode;
}
this.pdfViewer.currentScaleValue = this.#args.scaleValue;
this.pdfViewer.currentPageNumber = pageNumber;
this.#args = null;