1
0
Fork 0
mirror of https://github.com/futurepress/epub.js.git synced 2025-10-02 14:49:16 +02:00

Fixed locking to solve single page issues

This commit is contained in:
Fred Chasen 2015-06-05 15:20:45 -04:00
parent 61ebe6d16e
commit 23ca0b840d
8 changed files with 32 additions and 29 deletions

21
dist/epub.js vendored
View file

@ -4512,7 +4512,7 @@ EPUBJS.View.prototype.create = function() {
};
EPUBJS.View.prototype.lock = function(width, height) {
EPUBJS.View.prototype.lock = function(what, width, height) {
var elBorders = EPUBJS.core.borders(this.element);
var iframeBorders;
@ -4523,17 +4523,18 @@ EPUBJS.View.prototype.lock = function(width, height) {
iframeBorders = {width: 0, height: 0};
}
if(EPUBJS.core.isNumber(width)){
if(what == "width" && EPUBJS.core.isNumber(width)){
this.lockedWidth = width - elBorders.width - iframeBorders.width;
this.resize(this.lockedWidth, width); // width keeps ratio correct
}
if(EPUBJS.core.isNumber(height)){
if(what == "height" && EPUBJS.core.isNumber(height)){
this.lockedHeight = height - elBorders.height - iframeBorders.height;
this.resize(null, this.lockedHeight);
this.resize(width, this.lockedHeight);
}
if(EPUBJS.core.isNumber(width) &&
if(what === "both" &&
EPUBJS.core.isNumber(width) &&
EPUBJS.core.isNumber(height)){
this.lockedWidth = width - elBorders.width - iframeBorders.width;
@ -4957,6 +4958,7 @@ EPUBJS.Layout.Reflowable.prototype.calculate = function(_width, _height, _gap, _
this.column = colWidth;
this.gap = gap;
this.divisor = divisor;
};
EPUBJS.Layout.Reflowable.prototype.format = function(view){
@ -4980,7 +4982,6 @@ EPUBJS.Layout.Reflowable.prototype.format = function(view){
// Add extra padding for the gap between this and the next view
view.iframe.style.marginRight = this.gap+"px";
};
EPUBJS.Layout.Reflowable.prototype.count = function(view) {
@ -5372,9 +5373,9 @@ EPUBJS.Rendition.prototype._remove = function(view) {
EPUBJS.Rendition.prototype.resizeView = function(view) {
if(this.globalLayoutProperties.layout === "pre-paginated") {
view.lock(this.stage.width, this.stage.height);
view.lock("both", this.stage.width, this.stage.height);
} else {
view.lock(this.stage.width, null);
view.lock("width", this.stage.width, this.stage.height);
}
};
@ -6207,9 +6208,9 @@ EPUBJS.Continuous.prototype.scrollTo = function(x, y, silent){
EPUBJS.Continuous.prototype.resizeView = function(view) {
if(this.settings.axis === "horizontal") {
view.lock(null, this.stage.height);
view.lock("height", this.stage.width, this.stage.height);
} else {
view.lock(this.stage.width, null);
view.lock("width", this.stage.width, this.stage.height);
}
};

4
dist/epub.min.js vendored

File diff suppressed because one or more lines are too long

View file

@ -17,7 +17,7 @@
color: #333;
position: absolute;
height: 96.5%;
height: 100%;
width: 100%;
display: flex;
-webkit-align-items: center;
@ -26,7 +26,7 @@
#viewer {
width: 290px;
height: 100%;
height: 580px;
background: white;
box-shadow: 0 0 4px #ccc;
padding: 10px 10px 0px 10px;
@ -70,7 +70,10 @@
@media only screen
and (min-device-width : 320px)
and (max-device-width : 667px) {
and (max-device-width : 667px) {
#viewer {
height: 96.5%;
}
.arrow {
position: inherit;
display: none;
@ -84,7 +87,6 @@
<div id="prev" class="arrow"></div>
<div id="next" class="arrow"></div>
<script>
var currentSectionIndex = 14;
// Load the opf
// var book = ePub("https://s3.amazonaws.com/moby-dick/OPS/package.opf");
var book = ePub("../books/moby-dick/OPS/package.opf");
@ -93,9 +95,8 @@
width: "100%",
height: "100%"
});
// var pagination = rendition.paginate();
var displayed = rendition.display(currentSectionIndex);
var displayed = rendition.display();
displayed.then(function(renderer){

View file

@ -126,7 +126,7 @@
height: 600
});
var displayed = rendition.display("epubcfi(/6/14[xchapter_001]!4/2/30/2[c001p0016]/1:47)");
var displayed = rendition.display(4);
displayed.then(function(renderer){

View file

@ -541,9 +541,9 @@ EPUBJS.Continuous.prototype.scrollTo = function(x, y, silent){
EPUBJS.Continuous.prototype.resizeView = function(view) {
if(this.settings.axis === "horizontal") {
view.lock(null, this.stage.height);
view.lock("height", this.stage.width, this.stage.height);
} else {
view.lock(this.stage.width, null);
view.lock("width", this.stage.width, this.stage.height);
}
};

View file

@ -45,6 +45,7 @@ EPUBJS.Layout.Reflowable.prototype.calculate = function(_width, _height, _gap, _
this.column = colWidth;
this.gap = gap;
this.divisor = divisor;
};
EPUBJS.Layout.Reflowable.prototype.format = function(view){
@ -68,7 +69,6 @@ EPUBJS.Layout.Reflowable.prototype.format = function(view){
// Add extra padding for the gap between this and the next view
view.iframe.style.marginRight = this.gap+"px";
};
EPUBJS.Layout.Reflowable.prototype.count = function(view) {

View file

@ -305,9 +305,9 @@ EPUBJS.Rendition.prototype._remove = function(view) {
EPUBJS.Rendition.prototype.resizeView = function(view) {
if(this.globalLayoutProperties.layout === "pre-paginated") {
view.lock(this.stage.width, this.stage.height);
view.lock("both", this.stage.width, this.stage.height);
} else {
view.lock(this.stage.width, null);
view.lock("width", this.stage.width, this.stage.height);
}
};

View file

@ -78,7 +78,7 @@ EPUBJS.View.prototype.create = function() {
};
EPUBJS.View.prototype.lock = function(width, height) {
EPUBJS.View.prototype.lock = function(what, width, height) {
var elBorders = EPUBJS.core.borders(this.element);
var iframeBorders;
@ -89,17 +89,18 @@ EPUBJS.View.prototype.lock = function(width, height) {
iframeBorders = {width: 0, height: 0};
}
if(EPUBJS.core.isNumber(width)){
if(what == "width" && EPUBJS.core.isNumber(width)){
this.lockedWidth = width - elBorders.width - iframeBorders.width;
this.resize(this.lockedWidth, width); // width keeps ratio correct
}
if(EPUBJS.core.isNumber(height)){
if(what == "height" && EPUBJS.core.isNumber(height)){
this.lockedHeight = height - elBorders.height - iframeBorders.height;
this.resize(null, this.lockedHeight);
this.resize(width, this.lockedHeight);
}
if(EPUBJS.core.isNumber(width) &&
if(what === "both" &&
EPUBJS.core.isNumber(width) &&
EPUBJS.core.isNumber(height)){
this.lockedWidth = width - elBorders.width - iframeBorders.width;