From 03ec7a22f23f8e9697779eac29931a9eb7f2b65a Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 17 Apr 2022 10:53:34 +0200 Subject: [PATCH] Simplify spread-mode handling for the PAGE scroll-mode The spread-mode code in `BaseViewer.#ensurePageViewVisible`-method was initially copied from the `BaseViewer._updateSpreadMode`-method, which means that it's slightly more complicated than actually necessary. In particular, in the PAGE scroll-mode there can only be *one* spread active at a time and we thus don't need to handle insertion of multiple spread-divs. --- web/base_viewer.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/web/base_viewer.js b/web/base_viewer.js index 3a47df701..b40eb0d1e 100644 --- a/web/base_viewer.js +++ b/web/base_viewer.js @@ -920,24 +920,19 @@ class BaseViewer { } // Finally, append the new pages to the viewer and apply the spreadMode. - let spread = null; + const spread = document.createElement("div"); + spread.className = "spread"; + for (const i of pageIndexSet) { const pageView = this._pages[i]; if (!pageView) { continue; } - if (spread === null) { - spread = document.createElement("div"); - spread.className = "spread"; - viewer.appendChild(spread); - } else if (i % 2 === parity) { - spread = spread.cloneNode(false); - viewer.appendChild(spread); - } spread.appendChild(pageView.div); state.pages.push(pageView); } + viewer.appendChild(spread); } state.scrollDown = pageNumber >= state.previousPageNumber;