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

Add min spread width in determineLayoutProperties

This commit is contained in:
Fred Chasen 2016-09-06 14:36:54 +02:00
parent 4e7276c151
commit eed4a45cb6
7 changed files with 74 additions and 2032 deletions

2069
dist/epub.js vendored

File diff suppressed because it is too large Load diff

2
dist/epub.js.map vendored

File diff suppressed because one or more lines are too long

View file

@ -368,18 +368,23 @@ Contents.prototype.root = function() {
};
Contents.prototype.locationOf = function(target, ignoreClass) {
var position;
var targetPos = {"left": 0, "top": 0};
if(!this.document) return;
if(this.epubcfi.isCfiString(target)) {
range = new EpubCFI(cfi).toRange(this.document, ignoreClass);
range = new EpubCFI(target).toRange(this.document, ignoreClass);
if(range) {
if (range.startContainer.nodeType === Node.ELEMENT_NODE) {
targetPos = range.startContainer.getBoundingClientRect();
position = range.startContainer.getBoundingClientRect();
targetPos.left = position.left;
targetPos.top = position.top;
} else {
targetPos = range.getBoundingClientRect();
position = range.getBoundingClientRect();
targetPos.left = position.left;
targetPos.top = position.top;
}
}
@ -390,7 +395,9 @@ Contents.prototype.locationOf = function(target, ignoreClass) {
el = this.document.getElementById(id);
if(el) {
targetPos = el.getBoundingClientRect();
position = el.getBoundingClientRect();
targetPos.left = position.left;
targetPos.top = position.top;
}
}

View file

@ -5,7 +5,7 @@ function Layout(settings){
this.name = settings.layout || "reflowable";
this._flow = (settings.flow === "paginated") ? "paginated" : "scrolled";
this._spread = (settings.spread === "none") ? false : true;
this.minSpreadWidth = 800;
this._minSpreadWidth = settings.spread || 800;
this.width = 0;
this.height = 0;
@ -28,7 +28,7 @@ Layout.prototype.spread = function(spread, min) {
this._spread = (spread === "none") ? false : true;
if (min >= 0) {
this.minSpreadWidth = min;
this._minSpreadWidth = min;
}
}
@ -47,7 +47,7 @@ Layout.prototype.calculate = function(_width, _height, _gap){
var spreadWidth;
var delta;
if (this._spread && width >= this.minSpreadWidth) {
if (this._spread && width >= this._minSpreadWidth) {
divisor = 2;
} else {
divisor = 1;

View file

@ -437,6 +437,14 @@ ContinuousViewManager.prototype.onScroll = function(){
left: scrollLeft
});
clearTimeout(this.afterScrolled);
this.afterScrolled = setTimeout(function () {
this.trigger("scrolled", {
top: this.scrollTop,
left: this.scrollLeft
});
}.bind(this));
}
} else {

View file

@ -124,8 +124,6 @@ SingleViewManager.prototype.display = function(section, target){
var displaying = new RSVP.defer();
var displayed = displaying.promise;
var isCfi = EpubCFI().isCfiString(target);
// Check to make sure the section we want isn't already shown
var visible = this.views.find(section);

View file

@ -288,6 +288,7 @@ Rendition.prototype.determineLayoutProperties = function(metadata){
var orientation = this.settings.orientation || metadata.orientation || "auto";
var flow = this.settings.flow || metadata.flow || "auto";
var viewport = metadata.viewport || "";
var minSpreadWidth = this.settings.minSpreadWidth || metadata.minSpreadWidth || 800;
if (this.settings.width >= 0 && this.settings.height >= 0) {
viewport = "width="+this.settings.width+", height="+this.settings.height+"";
@ -298,7 +299,8 @@ Rendition.prototype.determineLayoutProperties = function(metadata){
spread : spread,
orientation : orientation,
flow : flow,
viewport : viewport
viewport : viewport,
minSpreadWidth : minSpreadWidth
};
return settings;