Skip to content

Commit

Permalink
Merge pull request futurepress#868 from mikkelvp/fixed
Browse files Browse the repository at this point in the history
Pre-paginated fixes
  • Loading branch information
fchasen authored Nov 24, 2018
2 parents 00414f3 + 9b4d7e8 commit 3d4c0e3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
24 changes: 18 additions & 6 deletions src/contents.js
Original file line number Diff line number Diff line change
Expand Up @@ -1049,20 +1049,32 @@ class Contents {
*/
fit(width, height){
var viewport = this.viewport();
var widthScale = width / parseInt(viewport.width);
var heightScale = height / parseInt(viewport.height);
var viewportWidth = parseInt(viewport.width);
var viewportHeight = parseInt(viewport.height);
var widthScale = width / viewportWidth;
var heightScale = height / viewportHeight;
var scale = widthScale < heightScale ? widthScale : heightScale;

var offsetY = (height - (viewport.height * scale)) / 2;
// the translate does not work as intended, elements can end up unaligned
// var offsetY = (height - (viewportHeight * scale)) / 2;
// var offsetX = 0;
// if (this.sectionIndex % 2 === 1) {
// offsetX = width - (viewportWidth * scale);
// }

this.layoutStyle("paginated");

this.width(width);
this.height(height);
// scale needs width and height to be set
this.width(viewportWidth);
this.height(viewportHeight);
this.overflow("hidden");

// Scale to the correct size
this.scaler(scale, 0, offsetY);
this.scaler(scale, 0, 0);
// this.scaler(scale, offsetX > 0 ? offsetX : 0, offsetY);

// background images are not scaled by transform
this.css("background-size", viewportWidth * scale + "px " + viewportHeight * scale + "px");

this.css("background-color", "transparent");
}
Expand Down
3 changes: 2 additions & 1 deletion src/managers/default/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,8 @@ class DefaultViewManager {
.then(function(){
var next;
if (this.layout.name === "pre-paginated" &&
this.layout.divisor > 1) {
this.layout.divisor > 1 && section.index > 0) {
// First page (cover) should stand alone for pre-paginated books
next = section.next();
if (next) {
return this.add(next);
Expand Down

0 comments on commit 3d4c0e3

Please sign in to comment.