mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-04 15:09:16 +02:00
Resizing based on container size
This commit is contained in:
parent
251ac3cdc4
commit
cf603fcca8
4 changed files with 162 additions and 58 deletions
|
@ -29,9 +29,27 @@ EPUBJS.View.prototype.create = function(width, height) {
|
|||
return this.iframe;
|
||||
};
|
||||
|
||||
EPUBJS.View.prototype.resize = function(width, height) {
|
||||
|
||||
if(width){
|
||||
this.iframe.style.width = width + "px";
|
||||
}
|
||||
|
||||
if(height){
|
||||
this.iframe.style.height = height + "px";
|
||||
}
|
||||
|
||||
if (!this.resizing) {
|
||||
this.resizing = true;
|
||||
this.expand();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
EPUBJS.View.prototype.resized = function(e) {
|
||||
|
||||
if (!this.resizing) {
|
||||
console.log("resize");
|
||||
this.expand();
|
||||
} else {
|
||||
this.resizing = false;
|
||||
|
@ -40,14 +58,14 @@ EPUBJS.View.prototype.resized = function(e) {
|
|||
};
|
||||
|
||||
EPUBJS.View.prototype.render = function(_request) {
|
||||
return this.section.render(_request)
|
||||
.then(function(contents){
|
||||
return this.load(contents);
|
||||
}.bind(this))
|
||||
.then(this.display.bind(this))
|
||||
.then(function(){
|
||||
this.rendering.resolve(this);
|
||||
}.bind(this));
|
||||
return this.section.render(_request)
|
||||
.then(function(contents){
|
||||
return this.load(contents);
|
||||
}.bind(this))
|
||||
.then(this.display.bind(this))
|
||||
.then(function(){
|
||||
this.rendering.resolve(this);
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
EPUBJS.View.prototype.load = function(contents) {
|
||||
|
@ -98,15 +116,17 @@ EPUBJS.View.prototype.display = function(contents) {
|
|||
|
||||
|
||||
|
||||
if(!this.document.fonts || this.document.fonts.status !== "loading") {
|
||||
this.expand();
|
||||
displaying.resolve(this);
|
||||
} else {
|
||||
this.document.fonts.onloading = function(){
|
||||
this.expand();
|
||||
displaying.resolve(this);
|
||||
}.bind(this);
|
||||
}
|
||||
// if(!this.document.fonts || this.document.fonts.status !== "loading") {
|
||||
// this.expand();
|
||||
// displaying.resolve(this);
|
||||
// } else {
|
||||
// this.document.fonts.onloading = function(){
|
||||
// this.expand();
|
||||
// displaying.resolve(this);
|
||||
// }.bind(this);
|
||||
// }
|
||||
this.expand();
|
||||
displaying.resolve(this);
|
||||
|
||||
// this.observer = this.observe(this.document.body);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue