mirror of
https://github.com/john-okeefe/foliate-js.git
synced 2026-09-09 11:29:14 -04:00
Avoid redundant render when setting spread before first display
This commit is contained in:
+3
-2
@@ -890,9 +890,10 @@ export class FixedLayout extends HTMLElement {
|
|||||||
|
|
||||||
#setSpread(value) {
|
#setSpread(value) {
|
||||||
this.spread = value;
|
this.spread = value;
|
||||||
const currentSection =
|
const started = this.#index >= 0;
|
||||||
this.book?.sections[this.index] ?? this.book?.sections[0];
|
const currentSection = started ? this.book?.sections[this.index] : null;
|
||||||
this.#computeSpreads();
|
this.#computeSpreads();
|
||||||
|
if (!started) return;
|
||||||
const resolved = currentSection ? this.getSpreadOf(currentSection) : null;
|
const resolved = currentSection ? this.getSpreadOf(currentSection) : null;
|
||||||
if (resolved) this.goToSpread(resolved.index, resolved.side, "page");
|
if (resolved) this.goToSpread(resolved.index, resolved.side, "page");
|
||||||
else this.#render();
|
else this.#render();
|
||||||
|
|||||||
Reference in New Issue
Block a user