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

added gap setting

This commit is contained in:
fchasen 2014-04-30 16:08:52 -07:00
parent 27f2f01bf7
commit 95b12179ab
11 changed files with 67 additions and 35 deletions

View file

@ -2266,6 +2266,7 @@ EPUBJS.Book = function(options){
layoutOveride : null, // Default: { spread: 'reflowable', layout: 'auto', orientation: 'auto'}
orientation : null,
minSpreadWidth: 800, //-- overridden by spread: none (never) / both (always)
gap: false, //-- False == auto
version: 1,
restore: false,
reload : false,
@ -2352,6 +2353,7 @@ EPUBJS.Book = function(options){
this.renderer = new EPUBJS.Renderer(this.settings.render_method);
//-- Set the width at which to switch from spreads to single pages
this.renderer.setMinSpreadWidth(this.settings.minSpreadWidth);
this.renderer.setGap(this.settings.gap);
//-- Pass through the renderer events
this.listenToRenderer(this.renderer);
@ -2573,6 +2575,8 @@ EPUBJS.Book.prototype.createHiddenRender = function(renderer, _width, _height) {
var hiddenContainer;
var hiddenEl;
renderer.setMinSpreadWidth(this.settings.minSpreadWidth);
renderer.setGap(this.settings.gap);
this._registerReplacements(renderer);
if(this.settings.forceSingle) {
renderer.forceSingle(true);
@ -4732,7 +4736,7 @@ EPUBJS.Layout.Reflowable = function(){
this.spreadWidth = null;
};
EPUBJS.Layout.Reflowable.prototype.format = function(documentElement, _width, _height){
EPUBJS.Layout.Reflowable.prototype.format = function(documentElement, _width, _height, _gap){
// Get the prefixed CSS commands
var columnAxis = EPUBJS.core.prefixed('columnAxis');
var columnGap = EPUBJS.core.prefixed('columnGap');
@ -4742,7 +4746,7 @@ EPUBJS.Layout.Reflowable.prototype.format = function(documentElement, _width, _h
var width = Math.floor(_width);
// var width = (fullWidth % 2 === 0) ? fullWidth : fullWidth - 0; // Not needed for single
var section = Math.floor(width / 8);
var gap = (section % 2 === 0) ? section : section - 1;
var gap = _gap || (section % 2 === 0) ? section : section - 1;
this.documentElement = documentElement;
//-- Single Page
this.spreadWidth = (width + gap);
@ -4786,7 +4790,7 @@ EPUBJS.Layout.ReflowableSpreads = function(){
this.spreadWidth = null;
};
EPUBJS.Layout.ReflowableSpreads.prototype.format = function(documentElement, _width, _height){
EPUBJS.Layout.ReflowableSpreads.prototype.format = function(documentElement, _width, _height, _gap){
var columnAxis = EPUBJS.core.prefixed('columnAxis');
var columnGap = EPUBJS.core.prefixed('columnGap');
var columnWidth = EPUBJS.core.prefixed('columnWidth');
@ -4799,7 +4803,7 @@ EPUBJS.Layout.ReflowableSpreads.prototype.format = function(documentElement, _wi
var width = (fullWidth % 2 === 0) ? fullWidth : fullWidth - 1;
var section = Math.floor(width / 8);
var gap = (section % 2 === 0) ? section : section - 1;
var gap = _gap || (section % 2 === 0) ? section : section - 1;
//-- Double Page
var colWidth = Math.floor((width - gap) / divisor);
@ -4843,7 +4847,7 @@ EPUBJS.Layout.Fixed = function(){
this.documentElement = null;
};
EPUBJS.Layout.Fixed = function(documentElement, _width, _height){
EPUBJS.Layout.Fixed = function(documentElement, _width, _height, _gap){
var columnWidth = EPUBJS.core.prefixed('columnWidth');
var viewport = documentElement.querySelector("[name=viewport");
var content;
@ -5799,7 +5803,7 @@ EPUBJS.Renderer.prototype.load = function(url){
this.doc = this.render.document;
// Format the contents using the current layout method
this.formated = this.layout.format(contents, this.render.width, this.render.height);
this.formated = this.layout.format(contents, this.render.width, this.render.height, this.gap);
this.render.setPageDimensions(this.formated.pageWidth, this.formated.pageHeight);
if(!this.initWidth && !this.initHeight){
@ -5930,7 +5934,7 @@ EPUBJS.Renderer.prototype.reformat = function(){
this.layoutMethod = this.determineLayout(this.layoutSettings);
this.layout = new EPUBJS.Layout[this.layoutMethod]();
this.formated = this.layout.format(this.contents, this.render.width, this.render.height);
this.formated = this.layout.format(this.contents, this.render.width, this.render.height, this.gap);
this.render.setPageDimensions(this.formated.pageWidth, this.formated.pageHeight);
pages = renderer.layout.calculatePages();
@ -6591,6 +6595,10 @@ EPUBJS.Renderer.prototype.forceSingle = function(bool){
}
};
EPUBJS.Renderer.prototype.setGap = function(gap){
this.gap = gap; //-- False == auto gap
};
//-- Content Replacements
EPUBJS.Renderer.prototype.replace = function(query, func, finished, progress){

File diff suppressed because one or more lines are too long

6
build/epub.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -2265,6 +2265,7 @@ EPUBJS.Book = function(options){
layoutOveride : null, // Default: { spread: 'reflowable', layout: 'auto', orientation: 'auto'}
orientation : null,
minSpreadWidth: 800, //-- overridden by spread: none (never) / both (always)
gap: false, //-- False == auto
version: 1,
restore: false,
reload : false,
@ -2351,6 +2352,7 @@ EPUBJS.Book = function(options){
this.renderer = new EPUBJS.Renderer(this.settings.render_method);
//-- Set the width at which to switch from spreads to single pages
this.renderer.setMinSpreadWidth(this.settings.minSpreadWidth);
this.renderer.setGap(this.settings.gap);
//-- Pass through the renderer events
this.listenToRenderer(this.renderer);
@ -2572,6 +2574,8 @@ EPUBJS.Book.prototype.createHiddenRender = function(renderer, _width, _height) {
var hiddenContainer;
var hiddenEl;
renderer.setMinSpreadWidth(this.settings.minSpreadWidth);
renderer.setGap(this.settings.gap);
this._registerReplacements(renderer);
if(this.settings.forceSingle) {
renderer.forceSingle(true);
@ -4731,7 +4735,7 @@ EPUBJS.Layout.Reflowable = function(){
this.spreadWidth = null;
};
EPUBJS.Layout.Reflowable.prototype.format = function(documentElement, _width, _height){
EPUBJS.Layout.Reflowable.prototype.format = function(documentElement, _width, _height, _gap){
// Get the prefixed CSS commands
var columnAxis = EPUBJS.core.prefixed('columnAxis');
var columnGap = EPUBJS.core.prefixed('columnGap');
@ -4741,7 +4745,7 @@ EPUBJS.Layout.Reflowable.prototype.format = function(documentElement, _width, _h
var width = Math.floor(_width);
// var width = (fullWidth % 2 === 0) ? fullWidth : fullWidth - 0; // Not needed for single
var section = Math.floor(width / 8);
var gap = (section % 2 === 0) ? section : section - 1;
var gap = _gap || (section % 2 === 0) ? section : section - 1;
this.documentElement = documentElement;
//-- Single Page
this.spreadWidth = (width + gap);
@ -4785,7 +4789,7 @@ EPUBJS.Layout.ReflowableSpreads = function(){
this.spreadWidth = null;
};
EPUBJS.Layout.ReflowableSpreads.prototype.format = function(documentElement, _width, _height){
EPUBJS.Layout.ReflowableSpreads.prototype.format = function(documentElement, _width, _height, _gap){
var columnAxis = EPUBJS.core.prefixed('columnAxis');
var columnGap = EPUBJS.core.prefixed('columnGap');
var columnWidth = EPUBJS.core.prefixed('columnWidth');
@ -4798,7 +4802,7 @@ EPUBJS.Layout.ReflowableSpreads.prototype.format = function(documentElement, _wi
var width = (fullWidth % 2 === 0) ? fullWidth : fullWidth - 1;
var section = Math.floor(width / 8);
var gap = (section % 2 === 0) ? section : section - 1;
var gap = _gap || (section % 2 === 0) ? section : section - 1;
//-- Double Page
var colWidth = Math.floor((width - gap) / divisor);
@ -4842,7 +4846,7 @@ EPUBJS.Layout.Fixed = function(){
this.documentElement = null;
};
EPUBJS.Layout.Fixed = function(documentElement, _width, _height){
EPUBJS.Layout.Fixed = function(documentElement, _width, _height, _gap){
var columnWidth = EPUBJS.core.prefixed('columnWidth');
var viewport = documentElement.querySelector("[name=viewport");
var content;
@ -5798,7 +5802,7 @@ EPUBJS.Renderer.prototype.load = function(url){
this.doc = this.render.document;
// Format the contents using the current layout method
this.formated = this.layout.format(contents, this.render.width, this.render.height);
this.formated = this.layout.format(contents, this.render.width, this.render.height, this.gap);
this.render.setPageDimensions(this.formated.pageWidth, this.formated.pageHeight);
if(!this.initWidth && !this.initHeight){
@ -5929,7 +5933,7 @@ EPUBJS.Renderer.prototype.reformat = function(){
this.layoutMethod = this.determineLayout(this.layoutSettings);
this.layout = new EPUBJS.Layout[this.layoutMethod]();
this.formated = this.layout.format(this.contents, this.render.width, this.render.height);
this.formated = this.layout.format(this.contents, this.render.width, this.render.height, this.gap);
this.render.setPageDimensions(this.formated.pageWidth, this.formated.pageHeight);
pages = renderer.layout.calculatePages();
@ -6590,6 +6594,10 @@ EPUBJS.Renderer.prototype.forceSingle = function(bool){
}
};
EPUBJS.Renderer.prototype.setGap = function(gap){
this.gap = gap; //-- False == auto gap
};
//-- Content Replacements
EPUBJS.Renderer.prototype.replace = function(query, func, finished, progress){

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

22
reader/js/epub.min.js vendored
View file

@ -2266,6 +2266,7 @@ EPUBJS.Book = function(options){
layoutOveride : null, // Default: { spread: 'reflowable', layout: 'auto', orientation: 'auto'}
orientation : null,
minSpreadWidth: 800, //-- overridden by spread: none (never) / both (always)
gap: false, //-- False == auto
version: 1,
restore: false,
reload : false,
@ -2352,6 +2353,7 @@ EPUBJS.Book = function(options){
this.renderer = new EPUBJS.Renderer(this.settings.render_method);
//-- Set the width at which to switch from spreads to single pages
this.renderer.setMinSpreadWidth(this.settings.minSpreadWidth);
this.renderer.setGap(this.settings.gap);
//-- Pass through the renderer events
this.listenToRenderer(this.renderer);
@ -2573,6 +2575,8 @@ EPUBJS.Book.prototype.createHiddenRender = function(renderer, _width, _height) {
var hiddenContainer;
var hiddenEl;
renderer.setMinSpreadWidth(this.settings.minSpreadWidth);
renderer.setGap(this.settings.gap);
this._registerReplacements(renderer);
if(this.settings.forceSingle) {
renderer.forceSingle(true);
@ -4732,7 +4736,7 @@ EPUBJS.Layout.Reflowable = function(){
this.spreadWidth = null;
};
EPUBJS.Layout.Reflowable.prototype.format = function(documentElement, _width, _height){
EPUBJS.Layout.Reflowable.prototype.format = function(documentElement, _width, _height, _gap){
// Get the prefixed CSS commands
var columnAxis = EPUBJS.core.prefixed('columnAxis');
var columnGap = EPUBJS.core.prefixed('columnGap');
@ -4742,7 +4746,7 @@ EPUBJS.Layout.Reflowable.prototype.format = function(documentElement, _width, _h
var width = Math.floor(_width);
// var width = (fullWidth % 2 === 0) ? fullWidth : fullWidth - 0; // Not needed for single
var section = Math.floor(width / 8);
var gap = (section % 2 === 0) ? section : section - 1;
var gap = _gap || (section % 2 === 0) ? section : section - 1;
this.documentElement = documentElement;
//-- Single Page
this.spreadWidth = (width + gap);
@ -4786,7 +4790,7 @@ EPUBJS.Layout.ReflowableSpreads = function(){
this.spreadWidth = null;
};
EPUBJS.Layout.ReflowableSpreads.prototype.format = function(documentElement, _width, _height){
EPUBJS.Layout.ReflowableSpreads.prototype.format = function(documentElement, _width, _height, _gap){
var columnAxis = EPUBJS.core.prefixed('columnAxis');
var columnGap = EPUBJS.core.prefixed('columnGap');
var columnWidth = EPUBJS.core.prefixed('columnWidth');
@ -4799,7 +4803,7 @@ EPUBJS.Layout.ReflowableSpreads.prototype.format = function(documentElement, _wi
var width = (fullWidth % 2 === 0) ? fullWidth : fullWidth - 1;
var section = Math.floor(width / 8);
var gap = (section % 2 === 0) ? section : section - 1;
var gap = _gap || (section % 2 === 0) ? section : section - 1;
//-- Double Page
var colWidth = Math.floor((width - gap) / divisor);
@ -4843,7 +4847,7 @@ EPUBJS.Layout.Fixed = function(){
this.documentElement = null;
};
EPUBJS.Layout.Fixed = function(documentElement, _width, _height){
EPUBJS.Layout.Fixed = function(documentElement, _width, _height, _gap){
var columnWidth = EPUBJS.core.prefixed('columnWidth');
var viewport = documentElement.querySelector("[name=viewport");
var content;
@ -5799,7 +5803,7 @@ EPUBJS.Renderer.prototype.load = function(url){
this.doc = this.render.document;
// Format the contents using the current layout method
this.formated = this.layout.format(contents, this.render.width, this.render.height);
this.formated = this.layout.format(contents, this.render.width, this.render.height, this.gap);
this.render.setPageDimensions(this.formated.pageWidth, this.formated.pageHeight);
if(!this.initWidth && !this.initHeight){
@ -5930,7 +5934,7 @@ EPUBJS.Renderer.prototype.reformat = function(){
this.layoutMethod = this.determineLayout(this.layoutSettings);
this.layout = new EPUBJS.Layout[this.layoutMethod]();
this.formated = this.layout.format(this.contents, this.render.width, this.render.height);
this.formated = this.layout.format(this.contents, this.render.width, this.render.height, this.gap);
this.render.setPageDimensions(this.formated.pageWidth, this.formated.pageHeight);
pages = renderer.layout.calculatePages();
@ -6591,6 +6595,10 @@ EPUBJS.Renderer.prototype.forceSingle = function(bool){
}
};
EPUBJS.Renderer.prototype.setGap = function(gap){
this.gap = gap; //-- False == auto gap
};
//-- Content Replacements
EPUBJS.Renderer.prototype.replace = function(query, func, finished, progress){

View file

@ -16,6 +16,7 @@ EPUBJS.Book = function(options){
layoutOveride : null, // Default: { spread: 'reflowable', layout: 'auto', orientation: 'auto'}
orientation : null,
minSpreadWidth: 800, //-- overridden by spread: none (never) / both (always)
gap: false, //-- False == auto
version: 1,
restore: false,
reload : false,
@ -102,6 +103,7 @@ EPUBJS.Book = function(options){
this.renderer = new EPUBJS.Renderer(this.settings.render_method);
//-- Set the width at which to switch from spreads to single pages
this.renderer.setMinSpreadWidth(this.settings.minSpreadWidth);
this.renderer.setGap(this.settings.gap);
//-- Pass through the renderer events
this.listenToRenderer(this.renderer);
@ -323,6 +325,8 @@ EPUBJS.Book.prototype.createHiddenRender = function(renderer, _width, _height) {
var hiddenContainer;
var hiddenEl;
renderer.setMinSpreadWidth(this.settings.minSpreadWidth);
renderer.setGap(this.settings.gap);
this._registerReplacements(renderer);
if(this.settings.forceSingle) {
renderer.forceSingle(true);

View file

@ -5,7 +5,7 @@ EPUBJS.Layout.Reflowable = function(){
this.spreadWidth = null;
};
EPUBJS.Layout.Reflowable.prototype.format = function(documentElement, _width, _height){
EPUBJS.Layout.Reflowable.prototype.format = function(documentElement, _width, _height, _gap){
// Get the prefixed CSS commands
var columnAxis = EPUBJS.core.prefixed('columnAxis');
var columnGap = EPUBJS.core.prefixed('columnGap');
@ -15,7 +15,7 @@ EPUBJS.Layout.Reflowable.prototype.format = function(documentElement, _width, _h
var width = Math.floor(_width);
// var width = (fullWidth % 2 === 0) ? fullWidth : fullWidth - 0; // Not needed for single
var section = Math.floor(width / 8);
var gap = (section % 2 === 0) ? section : section - 1;
var gap = _gap || (section % 2 === 0) ? section : section - 1;
this.documentElement = documentElement;
//-- Single Page
this.spreadWidth = (width + gap);
@ -59,7 +59,7 @@ EPUBJS.Layout.ReflowableSpreads = function(){
this.spreadWidth = null;
};
EPUBJS.Layout.ReflowableSpreads.prototype.format = function(documentElement, _width, _height){
EPUBJS.Layout.ReflowableSpreads.prototype.format = function(documentElement, _width, _height, _gap){
var columnAxis = EPUBJS.core.prefixed('columnAxis');
var columnGap = EPUBJS.core.prefixed('columnGap');
var columnWidth = EPUBJS.core.prefixed('columnWidth');
@ -72,7 +72,7 @@ EPUBJS.Layout.ReflowableSpreads.prototype.format = function(documentElement, _wi
var width = (fullWidth % 2 === 0) ? fullWidth : fullWidth - 1;
var section = Math.floor(width / 8);
var gap = (section % 2 === 0) ? section : section - 1;
var gap = _gap || (section % 2 === 0) ? section : section - 1;
//-- Double Page
var colWidth = Math.floor((width - gap) / divisor);
@ -116,7 +116,7 @@ EPUBJS.Layout.Fixed = function(){
this.documentElement = null;
};
EPUBJS.Layout.Fixed = function(documentElement, _width, _height){
EPUBJS.Layout.Fixed = function(documentElement, _width, _height, _gap){
var columnWidth = EPUBJS.core.prefixed('columnWidth');
var viewport = documentElement.querySelector("[name=viewport");
var content;

View file

@ -144,7 +144,7 @@ EPUBJS.Renderer.prototype.load = function(url){
this.doc = this.render.document;
// Format the contents using the current layout method
this.formated = this.layout.format(contents, this.render.width, this.render.height);
this.formated = this.layout.format(contents, this.render.width, this.render.height, this.gap);
this.render.setPageDimensions(this.formated.pageWidth, this.formated.pageHeight);
if(!this.initWidth && !this.initHeight){
@ -275,7 +275,7 @@ EPUBJS.Renderer.prototype.reformat = function(){
this.layoutMethod = this.determineLayout(this.layoutSettings);
this.layout = new EPUBJS.Layout[this.layoutMethod]();
this.formated = this.layout.format(this.contents, this.render.width, this.render.height);
this.formated = this.layout.format(this.contents, this.render.width, this.render.height, this.gap);
this.render.setPageDimensions(this.formated.pageWidth, this.formated.pageHeight);
pages = renderer.layout.calculatePages();
@ -936,6 +936,10 @@ EPUBJS.Renderer.prototype.forceSingle = function(bool){
}
};
EPUBJS.Renderer.prototype.setGap = function(gap){
this.gap = gap; //-- False == auto gap
};
//-- Content Replacements
EPUBJS.Renderer.prototype.replace = function(query, func, finished, progress){