Skip to content

Commit

Permalink
Merge pull request #14871 from Snuffleupagus/ensurePageViewVisible-Pr…
Browse files Browse the repository at this point in the history
…esentationMode-refactor

Re-factor the PresentationMode handling in `BaseViewer.#ensurePageViewVisible`
  • Loading branch information
timvandermeij authored May 4, 2022
2 parents 899e4d5 + aad4c65 commit 7d6d6f9
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions web/base_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -885,31 +885,21 @@ class BaseViewer {
// ... and clear out the active ones.
state.pages.length = 0;

if (this._spreadMode === SpreadMode.NONE) {
if (this._spreadMode === SpreadMode.NONE && !this.isInPresentationMode) {
// Finally, append the new page to the viewer.
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);
} else {
const pageIndexSet = new Set(),
parity = this._spreadMode - 1;

// 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.
pageIndexSet.add(pageNumber - 1);
pageIndexSet.add(pageNumber);
Expand All @@ -923,6 +913,13 @@ class BaseViewer {
const spread = document.createElement("div");
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) {
const pageView = this._pages[i];
if (!pageView) {
Expand Down

0 comments on commit 7d6d6f9

Please sign in to comment.