mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-04 15:09:16 +02:00
Pre-paginated fixes
This commit is contained in:
parent
0d36a49860
commit
9b4d7e8abe
2 changed files with 20 additions and 7 deletions
|
@ -1049,20 +1049,32 @@ class Contents {
|
||||||
*/
|
*/
|
||||||
fit(width, height){
|
fit(width, height){
|
||||||
var viewport = this.viewport();
|
var viewport = this.viewport();
|
||||||
var widthScale = width / parseInt(viewport.width);
|
var viewportWidth = parseInt(viewport.width);
|
||||||
var heightScale = height / parseInt(viewport.height);
|
var viewportHeight = parseInt(viewport.height);
|
||||||
|
var widthScale = width / viewportWidth;
|
||||||
|
var heightScale = height / viewportHeight;
|
||||||
var scale = widthScale < heightScale ? widthScale : heightScale;
|
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.layoutStyle("paginated");
|
||||||
|
|
||||||
this.width(width);
|
// scale needs width and height to be set
|
||||||
this.height(height);
|
this.width(viewportWidth);
|
||||||
|
this.height(viewportHeight);
|
||||||
this.overflow("hidden");
|
this.overflow("hidden");
|
||||||
|
|
||||||
// Scale to the correct size
|
// 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");
|
this.css("background-color", "transparent");
|
||||||
}
|
}
|
||||||
|
|
|
@ -283,7 +283,8 @@ class DefaultViewManager {
|
||||||
.then(function(){
|
.then(function(){
|
||||||
var next;
|
var next;
|
||||||
if (this.layout.name === "pre-paginated" &&
|
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();
|
next = section.next();
|
||||||
if (next) {
|
if (next) {
|
||||||
return this.add(next);
|
return this.add(next);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue