mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-04 15:09:16 +02:00
Fix viewport content parsing
This commit is contained in:
parent
a443bf00ce
commit
155c3f123a
4 changed files with 27 additions and 19 deletions
22
dist/epub.js
vendored
22
dist/epub.js
vendored
|
@ -6805,7 +6805,7 @@ Contents.prototype.viewport = function(options) {
|
|||
*/
|
||||
if($viewport && $viewport.hasAttribute("content")) {
|
||||
content = $viewport.getAttribute("content");
|
||||
contents = content.split(',');
|
||||
contents = content.split(/\s*,\s*/);
|
||||
if(contents[0]){
|
||||
width = contents[0].replace("width=", '').trim();
|
||||
}
|
||||
|
@ -7218,11 +7218,17 @@ Contents.prototype.columns = function(width, height, columnWidth, gap){
|
|||
this.css(COLUMN_WIDTH, columnWidth+"px");
|
||||
};
|
||||
|
||||
Contents.prototype.scale = function(scale){
|
||||
Contents.prototype.scale = function(scale, offsetX, offsetY){
|
||||
var scale = "scale(" + scale + ")";
|
||||
var translate = '';
|
||||
// this.css("position", "absolute"));
|
||||
this.css("transformOrigin", "top left");
|
||||
|
||||
this.css("transform", "scale(" + scale + ")");
|
||||
if (offsetX >= 0 || offsetY >= 0) {
|
||||
translate = " translate(" + (offsetX || 0 )+ "px, " + (offsetY || 0 )+ "px )";
|
||||
}
|
||||
|
||||
this.css("transform", scale + translate);
|
||||
};
|
||||
|
||||
Contents.prototype.fit = function(width, height){
|
||||
|
@ -7241,11 +7247,9 @@ Contents.prototype.fit = function(width, height){
|
|||
this.viewport({ scale: 1.0 });
|
||||
|
||||
// Scale to the correct size
|
||||
this.scale(scale);
|
||||
this.scale(scale, 0, offsetY);
|
||||
|
||||
this.css("backgroundColor", "transparent");
|
||||
|
||||
this.css("marginTop", offsetY + "px");
|
||||
};
|
||||
|
||||
|
||||
|
@ -13301,9 +13305,9 @@ IframeView.prototype.load = function(contents) {
|
|||
return loaded;
|
||||
}
|
||||
|
||||
this.document.open();
|
||||
this.document.write(contents);
|
||||
this.document.close();
|
||||
this.iframe.contentDocument.open();
|
||||
this.iframe.contentDocument.write(contents);
|
||||
this.iframe.contentDocument.close();
|
||||
|
||||
}
|
||||
|
||||
|
|
2
dist/epub.js.map
vendored
2
dist/epub.js.map
vendored
File diff suppressed because one or more lines are too long
|
@ -158,7 +158,7 @@ Contents.prototype.viewport = function(options) {
|
|||
*/
|
||||
if($viewport && $viewport.hasAttribute("content")) {
|
||||
content = $viewport.getAttribute("content");
|
||||
contents = content.split(',');
|
||||
contents = content.split(/\s*,\s*/);
|
||||
if(contents[0]){
|
||||
width = contents[0].replace("width=", '').trim();
|
||||
}
|
||||
|
@ -571,11 +571,17 @@ Contents.prototype.columns = function(width, height, columnWidth, gap){
|
|||
this.css(COLUMN_WIDTH, columnWidth+"px");
|
||||
};
|
||||
|
||||
Contents.prototype.scale = function(scale){
|
||||
Contents.prototype.scale = function(scale, offsetX, offsetY){
|
||||
var scale = "scale(" + scale + ")";
|
||||
var translate = '';
|
||||
// this.css("position", "absolute"));
|
||||
this.css("transformOrigin", "top left");
|
||||
|
||||
this.css("transform", "scale(" + scale + ")");
|
||||
if (offsetX >= 0 || offsetY >= 0) {
|
||||
translate = " translate(" + (offsetX || 0 )+ "px, " + (offsetY || 0 )+ "px )";
|
||||
}
|
||||
|
||||
this.css("transform", scale + translate);
|
||||
};
|
||||
|
||||
Contents.prototype.fit = function(width, height){
|
||||
|
@ -594,11 +600,9 @@ Contents.prototype.fit = function(width, height){
|
|||
this.viewport({ scale: 1.0 });
|
||||
|
||||
// Scale to the correct size
|
||||
this.scale(scale);
|
||||
this.scale(scale, 0, offsetY);
|
||||
|
||||
this.css("backgroundColor", "transparent");
|
||||
|
||||
this.css("marginTop", offsetY + "px");
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -385,9 +385,9 @@ IframeView.prototype.load = function(contents) {
|
|||
return loaded;
|
||||
}
|
||||
|
||||
this.document.open();
|
||||
this.document.write(contents);
|
||||
this.document.close();
|
||||
this.iframe.contentDocument.open();
|
||||
this.iframe.contentDocument.write(contents);
|
||||
this.iframe.contentDocument.close();
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue