From 09c18188a67a0affa10ec7368990f116611c70d1 Mon Sep 17 00:00:00 2001 From: Vincent Meyer Date: Fri, 10 May 2024 11:06:05 +0200 Subject: [PATCH] Fix blank page when resize occurs before first page is rendered --- src/managers/default/index.js | 7 ++++++- src/rendition.js | 7 +++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/managers/default/index.js b/src/managers/default/index.js index 2812d87..0d93610 100644 --- a/src/managers/default/index.js +++ b/src/managers/default/index.js @@ -233,7 +233,7 @@ class DefaultViewManager { this.emit(EVENTS.MANAGERS.RESIZED, { width: this._stageSize.width, height: this._stageSize.height - }, epubcfi); + }, epubcfi || this.target); } createView(section, forceRight) { @@ -265,6 +265,9 @@ class DefaultViewManager { target = undefined; } + // If the window is resized before rendered, call resize with original target + this.target = target + // Check to make sure the section we want isn't already shown var visible = this.views.find(section); @@ -897,6 +900,8 @@ class DefaultViewManager { this.scrollTop = scrollTop; this.scrollLeft = scrollLeft; + this.target = undefined + if(!this.ignore) { this.emit(EVENTS.MANAGERS.SCROLL, { top: scrollTop, diff --git a/src/rendition.js b/src/rendition.js index 14a21b4..e2dd1f9 100644 --- a/src/rendition.js +++ b/src/rendition.js @@ -476,8 +476,11 @@ class Rendition { height: size.height }, epubcfi); - if (this.location && this.location.start) { - this.display(epubcfi || this.location.start.cfi); + if (epubcfi) { + this.display(epubcfi) + } + else if (this.location && this.location.start) { + this.display(this.location.start.cfi); } }