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

[Bug] Blank page when resize happen during loading #1384

Open
vince4 opened this issue May 7, 2024 · 0 comments
Open

[Bug] Blank page when resize happen during loading #1384

vince4 opened this issue May 7, 2024 · 0 comments

Comments

@vince4
Copy link

vince4 commented May 7, 2024

I found an edge case pretty hard to reproduce.
When window.resize event is triggered while book.renderTo( is ongoing, the reader display a blank page with an empty div :

<div id="epubjs-container-42de2df8-43b2-4cb9-87b1-f371895d16de" class="epub-container" dir="ltr" style="word-spacing: 0px; line-height: 0; vertical-align: top; position: relative; display: flex; flex-flow: row; overflow: hidden; direction: ltr;"></div>

After long hours of exploration, I found that resize event empty the list of views in the manager.
Then, onResized get called in Rendition and should call display but it doesn't, because the location is not set already :

/**
   * Report resize events and display the last seen location
   * @private
   */
  onResized(size, epubcfi) {
    /**
     * Emit that the rendition has been resized
     * @event resized
     * @param {number} width
     * @param {height} height
     * @param {string} epubcfi (optional)
     * @memberof Rendition
     */
    this.emit(
      EVENTS.RENDITION.RESIZED,
      {
        width: size.width,
        height: size.height
      },
      epubcfi
    )

    if (this.location && this.location.start) {
      this.display(epubcfi || this.location.start.cfi)
    }
  }

I met two use cases. In the first one, the promise display was pending and in the second one, the promise display was completed.
I will try to propose a pull request soon.

@vince4 vince4 changed the title Blank page when resize happen during loading [Bug] Blank page when resize happen during loading May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant