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

Better loaderror handling

This commit is contained in:
Fred Chasen 2017-11-03 13:41:39 -07:00
parent 7c6fbfe978
commit b1093fa841
4 changed files with 38 additions and 17 deletions

View file

@ -236,9 +236,13 @@ class ContinuousViewManager extends DefaultViewManager {
// console.log("visible " + view.index);
if (!view.displayed) {
promises.push(view.display(this.request).then(function (view) {
view.show();
}));
let displayed = view.display(this.request)
.then(function (view) {
view.show();
}, (err) => {
view.hide();
});
promises.push(displayed);
} else {
view.show();
}
@ -256,7 +260,10 @@ class ContinuousViewManager extends DefaultViewManager {
}
if(promises.length){
return Promise.all(promises);
return Promise.all(promises)
.catch((err) => {
updating.reject(err);
})
} else {
updating.resolve();
return updating.promise;
@ -316,8 +323,9 @@ class ContinuousViewManager extends DefaultViewManager {
.then(() => {
// Check to see if anything new is on screen after rendering
return this.update(delta);
}, (err) => {
return err;
});
} else {
this.q.enqueue(function(){
this.update();

View file

@ -264,7 +264,9 @@ class DefaultViewManager {
this.moveTo(offset);
}
}.bind(this))
}.bind(this), (err) => {
displaying.reject(err);
})
.then(function(){
var next;
if (this.layout.name === "pre-paginated" &&
@ -445,7 +447,9 @@ class DefaultViewManager {
return this.append(right);
}
}
}.bind(this))
}.bind(this), (err) => {
displaying.reject(err);
})
.then(function(){
this.views.show();
}.bind(this));
@ -517,7 +521,9 @@ class DefaultViewManager {
return this.prepend(left);
}
}
}.bind(this))
}.bind(this), (err) => {
displaying.reject(err);
})
.then(function(){
if(this.isPaginated && this.settings.axis === "horizontal") {
if (this.settings.direction === "rtl") {

View file

@ -166,12 +166,14 @@ class IframeView {
resolve();
});
}.bind(this), function(e){
this.emit("loaderror", e);
return new Promise((resolve, reject) => {
reject(e);
});
}.bind(this))
.then(function() {
this.emit("rendered", this.section);
}.bind(this))
.catch(function(e){
this.emit("loaderror", e);
}.bind(this));
}
@ -445,15 +447,18 @@ class IframeView {
if (!this.displayed) {
this.render(request).then(function () {
this.render(request)
.then(function () {
this.emit("displayed", this);
this.onDisplayed(this);
this.emit("displayed", this);
this.onDisplayed(this);
this.displayed = true;
displayed.resolve(this);
this.displayed = true;
displayed.resolve(this);
}.bind(this));
}.bind(this), function (err) {
displayed.reject(err, this);
});
} else {
displayed.resolve(this);

View file

@ -271,6 +271,8 @@ class Rendition {
this.emit("displayed", section);
this.reportLocation();
}, (err) => {
this.emit("displayerror", err);
});
return displayed;