mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-04 15:09:16 +02:00
Fixed view.bounds to not return NaN
This commit is contained in:
parent
d733d41519
commit
19eeab40e3
5 changed files with 62 additions and 32 deletions
39
dist/epub.js
vendored
39
dist/epub.js
vendored
|
@ -4262,6 +4262,20 @@ EPUBJS.View = function(section) {
|
||||||
this.width = 0;
|
this.width = 0;
|
||||||
this.height = 0;
|
this.height = 0;
|
||||||
|
|
||||||
|
this.paddingTopBottom = 0;
|
||||||
|
this.paddingLeftRight = 0;
|
||||||
|
this.marginTopBottom = 0;
|
||||||
|
this.marginLeftRight = 0;
|
||||||
|
this.borderTopBottom = 0;
|
||||||
|
this.borderLeftRight = 0;
|
||||||
|
|
||||||
|
this.elpaddingTopBottom = 0;
|
||||||
|
this.elpaddingLeftRight = 0;
|
||||||
|
this.elmarginTopBottom = 0;
|
||||||
|
this.elmarginLeftRight = 0;
|
||||||
|
this.elborderTopBottom = 0;
|
||||||
|
this.elborderLeftRight = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
EPUBJS.View.prototype.create = function(width, height) {
|
EPUBJS.View.prototype.create = function(width, height) {
|
||||||
|
@ -4531,24 +4545,24 @@ EPUBJS.View.prototype.borders = function() {
|
||||||
if(this.iframe && !this.iframeStyle) {
|
if(this.iframe && !this.iframeStyle) {
|
||||||
this.iframeStyle = window.getComputedStyle(this.iframe);
|
this.iframeStyle = window.getComputedStyle(this.iframe);
|
||||||
|
|
||||||
this.paddingTopBottom = parseInt(this.iframeStyle.paddingTop) + parseInt(this.iframeStyle.paddingBottom) || 0;
|
this.paddingTopBottom = (parseInt(this.iframeStyle.paddingTop) + parseInt(this.iframeStyle.paddingBottom)) || 0;
|
||||||
this.paddingLeftRight = parseInt(this.iframeStyle.paddingLeft) + parseInt(this.iframeStyle.paddingRight) || 0;
|
this.paddingLeftRight = (parseInt(this.iframeStyle.paddingLeft) + parseInt(this.iframeStyle.paddingRight)) || 0;
|
||||||
this.marginTopBottom = parseInt(this.iframeStyle.marginTop) + parseInt(this.iframeStyle.marginBottom) || 0;
|
this.marginTopBottom = (parseInt(this.iframeStyle.marginTop) + parseInt(this.iframeStyle.marginBottom)) || 0;
|
||||||
this.marginLeftRight = parseInt(this.iframeStyle.marginLeft) + parseInt(this.iframeStyle.marginRight) || 0;
|
this.marginLeftRight = (parseInt(this.iframeStyle.marginLeft) + parseInt(this.iframeStyle.marginRight)) || 0;
|
||||||
this.borderTopBottom = parseInt(this.iframeStyle.borderTop) + parseInt(this.iframeStyle.borderBottom) || 0;
|
this.borderTopBottom = (parseInt(this.iframeStyle.borderTop) + parseInt(this.iframeStyle.borderBottom)) || 0;
|
||||||
this.borderLeftRight = parseInt(this.iframeStyle.borderLeft) + parseInt(this.iframeStyle.borderRight) || 0;
|
this.borderLeftRight = (parseInt(this.iframeStyle.borderLeft) + parseInt(this.iframeStyle.borderRight)) || 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.element && !this.elementStyle) {
|
if(this.element && !this.elementStyle) {
|
||||||
|
|
||||||
this.elementStyle = window.getComputedStyle(this.element);
|
this.elementStyle = window.getComputedStyle(this.element);
|
||||||
|
|
||||||
this.elpaddingTopBottom = parseInt(this.elementStyle.paddingTop) + parseInt(this.elementStyle.paddingBottom) || 0;
|
this.elpaddingTopBottom = (parseInt(this.elementStyle.paddingTop) + parseInt(this.elementStyle.paddingBottom)) || 0;
|
||||||
this.elpaddingLeftRight = parseInt(this.elementStyle.paddingLeft) + parseInt(this.elementStyle.paddingRight) || 0;
|
this.elpaddingLeftRight = (parseInt(this.elementStyle.paddingLeft) + parseInt(this.elementStyle.paddingRight)) || 0;
|
||||||
this.elmarginTopBottom = parseInt(this.elementStyle.marginTop) + parseInt(this.elementStyle.marginBottom) || 0;
|
this.elmarginTopBottom = (parseInt(this.elementStyle.marginTop) + parseInt(this.elementStyle.marginBottom)) || 0;
|
||||||
this.elmarginLeftRight = parseInt(this.elementStyle.marginLeft) + parseInt(this.elementStyle.marginRight) || 0;
|
this.elmarginLeftRight = (parseInt(this.elementStyle.marginLeft) + parseInt(this.elementStyle.marginRight)) || 0;
|
||||||
this.elborderTopBottom = parseInt(this.elementStyle.borderTop) + parseInt(this.elementStyle.borderBottom) || 0;
|
this.elborderTopBottom = (parseInt(this.elementStyle.borderTop) + parseInt(this.elementStyle.borderBottom)) || 0;
|
||||||
this.elborderLeftRight = parseInt(this.elementStyle.borderLeft) + parseInt(this.elementStyle.borderRight) || 0;
|
this.elborderLeftRight = (parseInt(this.elementStyle.borderLeft) + parseInt(this.elementStyle.borderRight)) || 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -4563,6 +4577,7 @@ EPUBJS.View.prototype.bounds = function() {
|
||||||
// width: this.element.offsetWidth,
|
// width: this.element.offsetWidth,
|
||||||
// height: this.element.offsetHeight
|
// height: this.element.offsetHeight
|
||||||
// };
|
// };
|
||||||
|
|
||||||
return {
|
return {
|
||||||
height: this.height + this.paddingTopBottom + this.marginTopBottom + this.borderTopBottom + this.elpaddingTopBottom + this.elmarginTopBottom + this.elborderTopBottom,
|
height: this.height + this.paddingTopBottom + this.marginTopBottom + this.borderTopBottom + this.elpaddingTopBottom + this.elmarginTopBottom + this.elborderTopBottom,
|
||||||
width: this.width + this.paddingLeftRight + this.marginLeftRight + this.borderLeftRight + this.elpaddingLeftRight + this.elmarginLeftRight + this.elborderLeftRight
|
width: this.width + this.paddingLeftRight + this.marginLeftRight + this.borderLeftRight + this.elpaddingLeftRight + this.elmarginLeftRight + this.elborderLeftRight
|
||||||
|
|
4
dist/epub.min.js
vendored
4
dist/epub.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -13,7 +13,6 @@
|
||||||
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||||
color: #333;
|
color: #333;
|
||||||
|
|
||||||
/* Center Content */
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
@ -33,7 +32,8 @@
|
||||||
/*width: 100%;*/
|
/*width: 100%;*/
|
||||||
/* height: 400px;*/
|
/* height: 400px;*/
|
||||||
position: relative;
|
position: relative;
|
||||||
|
/* Center Content */
|
||||||
|
margin: 40px auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
#viewer:after {
|
#viewer:after {
|
||||||
|
|
|
@ -22,6 +22,20 @@ EPUBJS.View = function(section) {
|
||||||
this.width = 0;
|
this.width = 0;
|
||||||
this.height = 0;
|
this.height = 0;
|
||||||
|
|
||||||
|
this.paddingTopBottom = 0;
|
||||||
|
this.paddingLeftRight = 0;
|
||||||
|
this.marginTopBottom = 0;
|
||||||
|
this.marginLeftRight = 0;
|
||||||
|
this.borderTopBottom = 0;
|
||||||
|
this.borderLeftRight = 0;
|
||||||
|
|
||||||
|
this.elpaddingTopBottom = 0;
|
||||||
|
this.elpaddingLeftRight = 0;
|
||||||
|
this.elmarginTopBottom = 0;
|
||||||
|
this.elmarginLeftRight = 0;
|
||||||
|
this.elborderTopBottom = 0;
|
||||||
|
this.elborderLeftRight = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
EPUBJS.View.prototype.create = function(width, height) {
|
EPUBJS.View.prototype.create = function(width, height) {
|
||||||
|
@ -291,24 +305,24 @@ EPUBJS.View.prototype.borders = function() {
|
||||||
if(this.iframe && !this.iframeStyle) {
|
if(this.iframe && !this.iframeStyle) {
|
||||||
this.iframeStyle = window.getComputedStyle(this.iframe);
|
this.iframeStyle = window.getComputedStyle(this.iframe);
|
||||||
|
|
||||||
this.paddingTopBottom = parseInt(this.iframeStyle.paddingTop) + parseInt(this.iframeStyle.paddingBottom) || 0;
|
this.paddingTopBottom = (parseInt(this.iframeStyle.paddingTop) + parseInt(this.iframeStyle.paddingBottom)) || 0;
|
||||||
this.paddingLeftRight = parseInt(this.iframeStyle.paddingLeft) + parseInt(this.iframeStyle.paddingRight) || 0;
|
this.paddingLeftRight = (parseInt(this.iframeStyle.paddingLeft) + parseInt(this.iframeStyle.paddingRight)) || 0;
|
||||||
this.marginTopBottom = parseInt(this.iframeStyle.marginTop) + parseInt(this.iframeStyle.marginBottom) || 0;
|
this.marginTopBottom = (parseInt(this.iframeStyle.marginTop) + parseInt(this.iframeStyle.marginBottom)) || 0;
|
||||||
this.marginLeftRight = parseInt(this.iframeStyle.marginLeft) + parseInt(this.iframeStyle.marginRight) || 0;
|
this.marginLeftRight = (parseInt(this.iframeStyle.marginLeft) + parseInt(this.iframeStyle.marginRight)) || 0;
|
||||||
this.borderTopBottom = parseInt(this.iframeStyle.borderTop) + parseInt(this.iframeStyle.borderBottom) || 0;
|
this.borderTopBottom = (parseInt(this.iframeStyle.borderTop) + parseInt(this.iframeStyle.borderBottom)) || 0;
|
||||||
this.borderLeftRight = parseInt(this.iframeStyle.borderLeft) + parseInt(this.iframeStyle.borderRight) || 0;
|
this.borderLeftRight = (parseInt(this.iframeStyle.borderLeft) + parseInt(this.iframeStyle.borderRight)) || 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.element && !this.elementStyle) {
|
if(this.element && !this.elementStyle) {
|
||||||
|
|
||||||
this.elementStyle = window.getComputedStyle(this.element);
|
this.elementStyle = window.getComputedStyle(this.element);
|
||||||
|
|
||||||
this.elpaddingTopBottom = parseInt(this.elementStyle.paddingTop) + parseInt(this.elementStyle.paddingBottom) || 0;
|
this.elpaddingTopBottom = (parseInt(this.elementStyle.paddingTop) + parseInt(this.elementStyle.paddingBottom)) || 0;
|
||||||
this.elpaddingLeftRight = parseInt(this.elementStyle.paddingLeft) + parseInt(this.elementStyle.paddingRight) || 0;
|
this.elpaddingLeftRight = (parseInt(this.elementStyle.paddingLeft) + parseInt(this.elementStyle.paddingRight)) || 0;
|
||||||
this.elmarginTopBottom = parseInt(this.elementStyle.marginTop) + parseInt(this.elementStyle.marginBottom) || 0;
|
this.elmarginTopBottom = (parseInt(this.elementStyle.marginTop) + parseInt(this.elementStyle.marginBottom)) || 0;
|
||||||
this.elmarginLeftRight = parseInt(this.elementStyle.marginLeft) + parseInt(this.elementStyle.marginRight) || 0;
|
this.elmarginLeftRight = (parseInt(this.elementStyle.marginLeft) + parseInt(this.elementStyle.marginRight)) || 0;
|
||||||
this.elborderTopBottom = parseInt(this.elementStyle.borderTop) + parseInt(this.elementStyle.borderBottom) || 0;
|
this.elborderTopBottom = (parseInt(this.elementStyle.borderTop) + parseInt(this.elementStyle.borderBottom)) || 0;
|
||||||
this.elborderLeftRight = parseInt(this.elementStyle.borderLeft) + parseInt(this.elementStyle.borderRight) || 0;
|
this.elborderLeftRight = (parseInt(this.elementStyle.borderLeft) + parseInt(this.elementStyle.borderRight)) || 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -323,6 +337,7 @@ EPUBJS.View.prototype.bounds = function() {
|
||||||
// width: this.element.offsetWidth,
|
// width: this.element.offsetWidth,
|
||||||
// height: this.element.offsetHeight
|
// height: this.element.offsetHeight
|
||||||
// };
|
// };
|
||||||
|
|
||||||
return {
|
return {
|
||||||
height: this.height + this.paddingTopBottom + this.marginTopBottom + this.borderTopBottom + this.elpaddingTopBottom + this.elmarginTopBottom + this.elborderTopBottom,
|
height: this.height + this.paddingTopBottom + this.marginTopBottom + this.borderTopBottom + this.elpaddingTopBottom + this.elmarginTopBottom + this.elborderTopBottom,
|
||||||
width: this.width + this.paddingLeftRight + this.marginLeftRight + this.borderLeftRight + this.elpaddingLeftRight + this.elmarginLeftRight + this.elborderLeftRight
|
width: this.width + this.paddingLeftRight + this.marginLeftRight + this.borderLeftRight + this.elpaddingLeftRight + this.elmarginLeftRight + this.elborderLeftRight
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue