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

Content resize (#605)

Wait after formatting, listen for resize events from `Contents`
This commit is contained in:
Fred Chasen 2017-04-24 17:08:53 -04:00 committed by GitHub
parent 32672359f5
commit 573ed8e18b
3 changed files with 21 additions and 12 deletions

View file

@ -293,6 +293,8 @@ class Contents {
this.removeEventListeners(); this.removeEventListeners();
this.removeSelectionListeners(); this.removeSelectionListeners();
clearTimeout(this.expanding);
} }
resizeListeners() { resizeListeners() {

View file

@ -146,22 +146,22 @@ class IframeView {
// apply the layout function to the contents // apply the layout function to the contents
this.settings.layout.format(this.contents); this.settings.layout.format(this.contents);
// Expand the iframe to the full size of the content
this.expand();
// Listen for events that require an expansion of the iframe // Listen for events that require an expansion of the iframe
this.addListeners(); this.addListeners();
if(show !== false) { // Wait for formating to apply
//this.q.enqueue(function(view){ return new Promise((resolve, reject) => {
// this.show(); setTimeout(() => {
//}, view); // Expand the iframe to the full size of the content
} this.expand();
// this.map = new Map(view, this.layout); resolve();
//this.hooks.show.trigger(view, this); }, 1);
this.emit("rendered", this.section); });
}.bind(this)) }.bind(this))
.then(function() {
this.emit("rendered", this.section);
}.bind(this))
.catch(function(e){ .catch(function(e){
this.emit("loaderror", e); this.emit("loaderror", e);
}.bind(this)); }.bind(this));
@ -432,7 +432,13 @@ class IframeView {
this.document.querySelector("head").appendChild(link); this.document.querySelector("head").appendChild(link);
} }
this.contents.on("expand", function () { this.contents.on("expand", () => {
if(this.displayed && this.iframe) {
this.expand();
}
});
this.contents.on("resize", (e) => {
if(this.displayed && this.iframe) { if(this.displayed && this.iframe) {
this.expand(); this.expand();
} }

View file

@ -613,6 +613,7 @@ class Rendition {
"page-break-inside": "avoid" "page-break-inside": "avoid"
} }
}); });
return new Promise(function(resolve, reject){ return new Promise(function(resolve, reject){
// Wait to apply // Wait to apply
setTimeout(function() { setTimeout(function() {