The epubjs reader's Rendition spread() function does not center the content properly when viewing a single page

Created an epub-reader component that is functioning as intended, but encountering alignment issues with certain epub files. In some cases, the first page of the book is always aligned to the left side instead of the center. These alignments can be adjusted in a popup window where you can choose between "spread to one page" or "spread to two pages".

Example of dialog:

<mat-radio-group [(ngModel)]="epubTextOptions.selectedTwoPages" class="inline-button">
      <mat-radio-button [value]="false" [checked]="!epubTextOptions.selectedTwoPages" class="inline-button">{{'reader.textOptions.dialog.onePage' | translate}}</mat-radio-button>
      <mat-radio-button [value]="true" [checked]="epubTextOptions.selectedTwoPages" class="inline-button">{{'reader.textOptions.dialog.twoPages' | translate}}</mat-radio-button>
    </mat-radio-group>

Typescript example:

export class MyClass implements OnInit {
  book: Book;
  rendition: Rendition;

  private myMethod() {

  this.rendition = this.book.renderTo(this.ePub.nativeElement, {
      width: '100%',
      height: '100%'
    });

    this.rendition.spread(this.epubTextOptions.selectedTwoPages ? 'always' : 'none');
  }
}

HTML component:

<div id="epubContent" class="d-flex align-items-center" [style.height]="contentHeight + 'px'">
  <app-button *ngIf="displayPrevPageButton() && !isMobileDevice()" (btnClick)="prevPage()"
              btnClass="mat-icon-button epub-action"><span class="far fa-chevron-left"></span></app-button>
  <div #ePub class="epub-container"></div>
  <app-button *ngIf="displayNextPageButton() && !isMobileDevice()" (btnClick)="nextPage()"
              btnClass="mat-icon-button epub-action"><span class="far fa-chevron-right"></span></app-button>
</div>

The functionality is based on examples from the epubjs library and customized for the reader. However, some epub files may not align correctly when selecting "one page" instead of center alignment.

Answer №1

When it comes to comparing Well in vs, I believe there is a technique called fill that automatically aligns everything accordingly. You could try implementing a similar approach, as I have not had experience with epub before.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Navigating through a mergeMap observable with an undefined value

In my Angular 6 app, I have a class that attaches API tokens to every http request using the getIdToken() method. If the token retrieval is successful, everything works fine. However, if it fails, my app will stop functioning. I need help with handling th ...

What are the Typescript definitions for managing events and handlers for checkboxes in React?

I am currently working on a project similar to this React example but in Typescript. The main objective is to create a parent component with state, and have multiple stateless child components that communicate back their interactions to the parent. Since ...

Issue: Unable to locate 'child_process' in Angular 5

I am a newcomer to Angular, and I have encountered a requirement in my project to retrieve the MAC address of the user's system. To achieve this, I performed an NPM installation as shown below: npm install --save macaddress Next, I added the follow ...

How to automatically insert a page break after a certain string in an array using JavaScript

I've created a code that is intended to implement page breaks after a specific number of new lines or words. I have defined an array that indicates where these breaks should occur within my element. In the example provided in my jsFiddle, you can see ...

The VueJs Method has the ability to directly alter a given response

Within my parent component, I am connecting to the backend using a query. Through interactions with the navbar and utilizing my activeView data in the parent component, I trigger the rendering of a new child page upon clicks and pass a prop from the respon ...

What is the syntax for accessing a nested object within the .find method?

Currently building an application in node.js. I am struggling with referencing the "email" element in the "userData" object within the Order model when using the find method. Any suggestions on how to properly refer to it? Order model: const orderSchema = ...

Is there a method to make this package compatible with Angular version 16?

I recently integrated the ngx-hotjar package version 11.0.0 into my Angular 10 project with success. However, when trying to use it in a new Angular 16 project, I encountered the following error during ng serve: Error: src/app/app.module.ts:275:12 - error ...

Attempt to retrieve node information using the useStaticQuery method in Gatsby

I am facing an issue where I am trying to retrieve information from GraphQL Gatsby using useStaticQuery, but the data returned is showing as undefined. I am confused as to why this is happening because when I check my http://localhost:8000/___graphql endpo ...

Issues with JQuery .attr method not functioning as expected

I'm having trouble with the .attr() function in jQuery. It doesn't seem to be changing the background-color of the div with the id "outline" like I expected. Here's an example of my code: <div id="outline"></div> And here is t ...

Finding subsetsums in Javascript

I'm facing an issue with my JavaScript code that seems to be causing it not to run properly. <p id="demo"></p> Here is the JS code: function isSubsetSum(arr, n, sum) { if (sum == 0) { return true; } if (n == 0 && sum ...

Unlock the Power of jQuery Hashing with the Addition of Additional Variables

Looking for a way to include an additional variable in a URL like the one above. I've experimented with different methods but I'm not certain which is the most effective. For example: Currently using JQUERY to detect the HASH value: if (window ...

Code displayed on Facebook when sharing a website link implemented in JavaScript

Is there a way to prevent javascript code from appearing in Facebook posts when sharing links, whether it's done manually or through programming? I'm specifically looking for solutions to fix my website so that when I post links on Facebook, the ...

Conceal the div with ID "en" if the value matches $en

Looking for assistance with language settings on my page. I have a menu where I can select English, Croatian, or German. Below is the code to manage language changes: <?php class home_header_language { protected $_DBconn; ...

javascript Regular Expressions

There's a string with multiple user names: "rb40425,Fri Jan 30 11:35:33 2015@ot7293,Fri Jan...." Desiring to extract only the user names using RegEx in JavaScript, like rb40425 and ot7293. This is my current attempt: replace(/,.*/, ""); However, i ...

Share the connection to the MongoDB database with the models.js file

Here is the content of the app.js file: var express = require('express'); var path = require('path'); var mongoose = require('mongoose'); var bodyparser = require('body-parser'); var conn = mongoose.createConnecti ...

Do the Firebase v3 JS libraries have a debug version that is not obfuscated or minified?

In the earlier versions before 3.0, there used to be a "debug" version of the library that could be accessed by adding -debug to the filename. For instance, v2.4.2 had an obfuscated variation along with a debug variant. However, it seems like v3.1.0 only ...

The use of JQuery insertAfter function in Chrome and Safari results in the content being inserted as a string representation

Currently, I am utilizing jQuery to dynamically insert rows into a table. The row itself acts as a text template, with certain elements being replaced before being converted into a jQuery DOM node. This process works smoothly in Firefox and IE: jQuery(jQu ...

Tips for sorting through and minimizing data based on the most recent date

info = { start: 1, data: [ { name: 'Maria', date: '2020-02-15 }, { name: 'Paula', date: '2020-06-10 }, { name: 'Eva', date: '2020-12-05 }, { name: 'Sophia', date ...

Utilizing a JQuery variable as an OFFSET parameter in an SQL query

Currently, I am working on incorporating infinite scroll functionality for posts within a news feed. The idea is for the posts to be dynamically loaded into the news feed when the user reaches the footer. The Challenge I am facing an issue with inc ...

Steps to resolve the issue: The current experimental syntax 'classProperties' is not supported

I encountered an issue where the experimental syntax 'classProperties' is not supported when trying to run my react js application. My goal is to increment the value inside a <span> when a ` button is clicked. Below is the excerpt of my c ...