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

Move scrolling to Infinite, fix horz scroll

This commit is contained in:
Fred Chasen 2014-11-25 23:20:28 -05:00
parent e09f007e13
commit b1ebc754cd
9 changed files with 553 additions and 505 deletions

View file

@ -1,7 +1,8 @@
EPUBJS.Layout = EPUBJS.Layout || {};
EPUBJS.Layout.Reflowable = function(){
this.documentElement = null;
EPUBJS.Layout.Reflowable = function(view){
// this.documentElement = null;
this.view = view;
this.spreadWidth = null;
};
@ -56,12 +57,13 @@ EPUBJS.Layout.Reflowable.prototype.calculatePages = function() {
};
};
EPUBJS.Layout.ReflowableSpreads = function(){
this.documentElement = null;
EPUBJS.Layout.ReflowableSpreads = function(view){
this.view = view;
this.documentElement = view.document.documentElement;
this.spreadWidth = null;
};
EPUBJS.Layout.ReflowableSpreads.prototype.format = function(view, _width, _height, _gap){
EPUBJS.Layout.ReflowableSpreads.prototype.format = function(_width, _height, _gap){
var columnAxis = EPUBJS.core.prefixed('columnAxis');
var columnGap = EPUBJS.core.prefixed('columnGap');
var columnWidth = EPUBJS.core.prefixed('columnWidth');
@ -83,25 +85,27 @@ EPUBJS.Layout.ReflowableSpreads.prototype.format = function(view, _width, _heigh
this.spreadWidth = (colWidth + gap) * divisor;
view.document.documentElement.style.overflow = "hidden";
this.view.document.documentElement.style.overflow = "hidden";
// Must be set to the new calculated width or the columns will be off
view.document.body.style.width = width + "px";
this.view.document.body.style.width = width + "px";
//-- Adjust height
view.document.body.style.height = _height + "px";
this.view.document.body.style.height = _height + "px";
//-- Add columns
view.document.body.style[columnAxis] = "horizontal";
view.document.body.style[columnFill] = "auto";
view.document.body.style[columnGap] = gap+"px";
view.document.body.style[columnWidth] = colWidth+"px";
this.view.document.body.style[columnAxis] = "horizontal";
this.view.document.body.style[columnFill] = "auto";
this.view.document.body.style[columnGap] = gap+"px";
this.view.document.body.style[columnWidth] = colWidth+"px";
this.colWidth = colWidth;
this.gap = gap;
view.iframe.style.width = colWidth+"px";
view.iframe.style.paddingRight = gap+"px";
this.view.document.body.style.paddingRight = gap + "px";
// view.iframe.style.width = this.spreadWidth+"px";
// this.view.element.style.paddingRight = gap+"px";
// view.iframe.style.paddingLeft = gap+"px";
return {
pageWidth : this.spreadWidth,
@ -109,12 +113,12 @@ EPUBJS.Layout.ReflowableSpreads.prototype.format = function(view, _width, _heigh
};
};
EPUBJS.Layout.ReflowableSpreads.prototype.calculatePages = function() {
EPUBJS.Layout.ReflowableSpreads.prototype.calculatePages = function(view) {
var totalWidth = this.documentElement.scrollWidth;
var displayedPages = Math.ceil(totalWidth / this.spreadWidth);
//-- Add a page to the width of the document to account an for odd number of pages
this.documentElement.style.width = totalWidth + this.spreadWidth + "px";
// this.documentElement.style.width = totalWidth + this.spreadWidth + "px";
return {
displayedPages : displayedPages,
pageCount : displayedPages * 2