Merge pull request #14871 from Snuffleupagus/ensurePageViewVisible-PresentationMode-refactor

Re-factor the PresentationMode handling in `BaseViewer.#ensurePageViewVisible`
This commit is contained in:
Tim van der Meij 2022-05-04 22:41:29 +02:00 committed by GitHub
commit 7d6d6f9151
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -885,23 +885,10 @@ class BaseViewer {
// ... and clear out the active ones. // ... and clear out the active ones.
state.pages.length = 0; state.pages.length = 0;
if (this._spreadMode === SpreadMode.NONE) { if (this._spreadMode === SpreadMode.NONE && !this.isInPresentationMode) {
// Finally, append the new page to the viewer. // Finally, append the new page to the viewer.
const pageView = this._pages[pageNumber - 1]; const pageView = this._pages[pageNumber - 1];
if (this.isInPresentationMode) {
const spread = document.createElement("div");
spread.className = "spread";
const dummyPage = document.createElement("div");
dummyPage.className = "dummyPage";
dummyPage.style.height = `${this.container.clientHeight}px`;
spread.appendChild(dummyPage);
spread.appendChild(pageView.div);
viewer.appendChild(spread);
} else {
viewer.appendChild(pageView.div); viewer.appendChild(pageView.div);
}
state.pages.push(pageView); state.pages.push(pageView);
} else { } else {
@ -909,7 +896,10 @@ class BaseViewer {
parity = this._spreadMode - 1; parity = this._spreadMode - 1;
// Determine the pageIndices in the new spread. // Determine the pageIndices in the new spread.
if (pageNumber % 2 !== parity) { if (parity === -1) {
// PresentationMode is active, with `SpreadMode.NONE` set.
pageIndexSet.add(pageNumber - 1);
} else if (pageNumber % 2 !== parity) {
// Left-hand side page. // Left-hand side page.
pageIndexSet.add(pageNumber - 1); pageIndexSet.add(pageNumber - 1);
pageIndexSet.add(pageNumber); pageIndexSet.add(pageNumber);
@ -923,6 +913,13 @@ class BaseViewer {
const spread = document.createElement("div"); const spread = document.createElement("div");
spread.className = "spread"; spread.className = "spread";
if (this.isInPresentationMode) {
const dummyPage = document.createElement("div");
dummyPage.className = "dummyPage";
dummyPage.style.height = `${this.container.clientHeight}px`;
spread.appendChild(dummyPage);
}
for (const i of pageIndexSet) { for (const i of pageIndexSet) {
const pageView = this._pages[i]; const pageView = this._pages[i];
if (!pageView) { if (!pageView) {