Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-factor the PresentationMode handling in BaseViewer.#ensurePageViewVisible #14871

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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