mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-04 15:09:16 +02:00
Scale fixed-layout books
This commit is contained in:
parent
7b7e4d75a3
commit
06b7ad3adf
1 changed files with 13 additions and 0 deletions
|
@ -125,6 +125,8 @@ EPUBJS.Layout.Fixed = function(){
|
|||
|
||||
EPUBJS.Layout.Fixed.prototype.format = function(documentElement, _width, _height, _gap){
|
||||
var columnWidth = EPUBJS.core.prefixed('columnWidth');
|
||||
var transform = EPUBJS.core.prefixed('transform');
|
||||
var transformOrigin = EPUBJS.core.prefixed('transformOrigin');
|
||||
var viewport = documentElement.querySelector("[name=viewport]");
|
||||
var content;
|
||||
var contents;
|
||||
|
@ -145,6 +147,17 @@ EPUBJS.Layout.Fixed.prototype.format = function(documentElement, _width, _height
|
|||
}
|
||||
}
|
||||
|
||||
//-- Scale fixed documents so their contents don't overflow, and
|
||||
// vertically and horizontally center the contents
|
||||
var widthScale = _width / width;
|
||||
var heightScale = _height / height;
|
||||
var scale = widthScale < heightScale ? widthScale : heightScale;
|
||||
documentElement.style.position = "absolute";
|
||||
documentElement.style.top = "50%";
|
||||
documentElement.style.left = "50%";
|
||||
documentElement.style[transform] = "scale(" + scale + ") translate(-50%, -50%)";
|
||||
documentElement.style[transformOrigin] = "0px 0px 0px";
|
||||
|
||||
//-- Adjust width and height
|
||||
documentElement.style.width = width + "px" || "auto";
|
||||
documentElement.style.height = height + "px" || "auto";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue