1
0
Fork 0
mirror of https://github.com/futurepress/epub.js.git synced 2025-10-04 15:09:16 +02:00

Add margin to align pre-paginated pages

This commit is contained in:
Mikkel Vester Petersen 2019-08-13 14:00:50 +02:00
parent bf4a68a9a2
commit dfce8e58b7
3 changed files with 9 additions and 4 deletions

View file

@ -1070,7 +1070,7 @@ class Contents {
* @param {number} width * @param {number} width
* @param {number} height * @param {number} height
*/ */
fit(width, height){ fit(width, height, section){
var viewport = this.viewport(); var viewport = this.viewport();
var viewportWidth = parseInt(viewport.width); var viewportWidth = parseInt(viewport.width);
var viewportHeight = parseInt(viewport.height); var viewportHeight = parseInt(viewport.height);
@ -1100,6 +1100,11 @@ class Contents {
this.css("background-size", viewportWidth * scale + "px " + viewportHeight * scale + "px"); this.css("background-size", viewportWidth * scale + "px " + viewportHeight * scale + "px");
this.css("background-color", "transparent"); this.css("background-color", "transparent");
if (section && section.properties.includes("page-spread-left")) {
// set margin since scale is weird
var marginLeft = width - (viewportWidth * scale);
this.css("margin-left", marginLeft + "px");
}
} }
/** /**

View file

@ -189,11 +189,11 @@ class Layout {
* @param {Contents} contents * @param {Contents} contents
* @return {Promise} * @return {Promise}
*/ */
format(contents){ format(contents, section){
var formating; var formating;
if (this.name === "pre-paginated") { if (this.name === "pre-paginated") {
formating = contents.fit(this.columnWidth, this.height); formating = contents.fit(this.columnWidth, this.height, section);
} else if (this._flow === "paginated") { } else if (this._flow === "paginated") {
formating = contents.columns(this.width, this.height, this.columnWidth, this.gap); formating = contents.columns(this.width, this.height, this.columnWidth, this.gap);
} else { // scrolled } else { // scrolled

View file

@ -149,7 +149,7 @@ class IframeView {
.then(function(){ .then(function(){
// apply the layout function to the contents // apply the layout function to the contents
this.layout.format(this.contents); this.layout.format(this.contents, this.section);
// find and report the writingMode axis // find and report the writingMode axis
let writingMode = this.contents.writingMode(); let writingMode = this.contents.writingMode();