mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-03 14:59:18 +02:00
Callbacks for layout
This commit is contained in:
parent
1547830c36
commit
35701e5db7
3 changed files with 46 additions and 29 deletions
|
@ -1,4 +1,5 @@
|
|||
var core = require('./core');
|
||||
var RSVP = require('rsvp');
|
||||
|
||||
function Reflowable(){
|
||||
this.columnAxis = core.prefixed('columnAxis');
|
||||
|
@ -64,36 +65,37 @@ Reflowable.prototype.calculate = function(_width, _height, _gap, _devisor){
|
|||
};
|
||||
|
||||
Reflowable.prototype.format = function(contents){
|
||||
|
||||
var promises = [];
|
||||
// var $doc = doc.documentElement;
|
||||
// var $body = doc.body;//view.document.querySelector("body");
|
||||
|
||||
// $doc.style.overflow = "hidden";
|
||||
contents.overflow("hidden");
|
||||
promises.push(contents.overflow("hidden"));
|
||||
|
||||
// Must be set to the new calculated width or the columns will be off
|
||||
// $body.style.width = this.width + "px";
|
||||
// $doc.style.width = this.width + "px";
|
||||
contents.width(this.width);
|
||||
promises.push(contents.width(this.width));
|
||||
|
||||
//-- Adjust height
|
||||
// $body.style.height = this.height + "px";
|
||||
contents.height(this.height);
|
||||
promises.push(contents.height(this.height));
|
||||
|
||||
contents.css("margin", "0");
|
||||
promises.push(contents.css("margin", "0"));
|
||||
|
||||
//-- Add columns
|
||||
// $body.style[this.columnAxis] = "horizontal";
|
||||
contents.css(this.columnAxis, "horizontal");
|
||||
promises.push(contents.css(this.columnAxis, "horizontal"));
|
||||
// $body.style[this.columnFill] = "auto";
|
||||
contents.css(this.columnFill, "auto");
|
||||
promises.push(contents.css(this.columnFill, "auto"));
|
||||
// $body.style[this.columnGap] = this.gap+"px";
|
||||
contents.css(this.columnGap, this.gap+"px");
|
||||
promises.push(contents.css(this.columnGap, this.gap+"px"));
|
||||
// $body.style[this.columnWidth] = this.column +"px";
|
||||
contents.css(this.columnWidth, this.column+"px");
|
||||
promises.push(contents.css(this.columnWidth, this.column+"px"));
|
||||
|
||||
// Add extra padding for the gap between this and the next view
|
||||
// view.iframe.style.marginRight = this.gap+"px";
|
||||
return RSVP.all(promises);
|
||||
};
|
||||
|
||||
Reflowable.prototype.count = function(totalWidth) {
|
||||
|
@ -120,6 +122,7 @@ Fixed.prototype.calculate = function(_width, _height){
|
|||
};
|
||||
|
||||
Fixed.prototype.format = function(contents){
|
||||
var promises = [];
|
||||
var viewport = contents.viewport();
|
||||
// var width, height;
|
||||
//
|
||||
|
@ -145,16 +148,18 @@ Fixed.prototype.format = function(contents){
|
|||
// $doc.style.width = width + "px" || "auto";
|
||||
// $doc.style.height = height + "px" || "auto";
|
||||
if (viewport.width) {
|
||||
contents.width(viewport.width);
|
||||
promises.push(contents.width(viewport.width));
|
||||
}
|
||||
|
||||
if (viewport.height) {
|
||||
contents.height(viewport.height);
|
||||
promises.push(contents.height(viewport.height));
|
||||
}
|
||||
|
||||
//-- Scroll
|
||||
// $doc.style.overflow = "auto";
|
||||
contents.overflow("auto");
|
||||
promises.push(contents.overflow("auto"));
|
||||
|
||||
return RSVP.all(promises);
|
||||
|
||||
};
|
||||
|
||||
|
@ -181,13 +186,15 @@ Scroll.prototype.calculate = function(_width, _height){
|
|||
};
|
||||
|
||||
Scroll.prototype.format = function(contents){
|
||||
|
||||
var promises = [];
|
||||
// var $doc = doc.documentElement;
|
||||
|
||||
// $doc.style.width = "auto";
|
||||
// $doc.style.height = "auto";
|
||||
// contents.width("auto");
|
||||
contents.height("auto");
|
||||
promises.push(contents.height("auto"));
|
||||
|
||||
return RSVP.all(promises);
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue