From ed6400ddcb6a2896ef7133bf43d9a1c8013780fa Mon Sep 17 00:00:00 2001 From: Protected Date: Fri, 30 May 2025 09:46:42 +0100 Subject: [PATCH] Re-render single pages when paginating fixed layout (#61) --- fixed-layout.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/fixed-layout.js b/fixed-layout.js index bf713da..e742914 100644 --- a/fixed-layout.js +++ b/fixed-layout.js @@ -179,18 +179,18 @@ export class FixedLayout extends HTMLElement { #goLeft() { if (this.#center || this.#left?.blank) return if (this.#portrait && this.#left?.element?.style?.display === 'none') { - this.#right.element.style.display = 'none' - this.#left.element.style.display = 'block' this.#side = 'left' + this.#render() + this.#reportLocation('page') return true } } #goRight() { if (this.#center || this.#right?.blank) return if (this.#portrait && this.#right?.element?.style?.display === 'none') { - this.#left.element.style.display = 'none' - this.#right.element.style.display = 'block' this.#side = 'right' + this.#render() + this.#reportLocation('page') return true } } @@ -295,13 +295,11 @@ export class FixedLayout extends HTMLElement { } async next() { const s = this.rtl ? this.#goLeft() : this.#goRight() - if (s) this.#reportLocation('page') - else return this.goToSpread(this.#index + 1, this.rtl ? 'right' : 'left', 'page') + if (!s) return this.goToSpread(this.#index + 1, this.rtl ? 'right' : 'left', 'page') } async prev() { const s = this.rtl ? this.#goRight() : this.#goLeft() - if (s) this.#reportLocation('page') - else return this.goToSpread(this.#index - 1, this.rtl ? 'left' : 'right', 'page') + if (!s) return this.goToSpread(this.#index - 1, this.rtl ? 'left' : 'right', 'page') } getContents() { return Array.from(this.#root.querySelectorAll('iframe'), frame => ({