Don't fail on broken images

This commit is contained in:
MoyuScript
2014-03-15 13:20:05 +02:00
parent 6e1baa3e25
commit 73266849b4
5 changed files with 42 additions and 12 deletions

View File

@@ -0,0 +1,17 @@
function DummyImageContainer(src) {
this.src = src;
log("DummyImageContainer for", src);
if (!this.promise || !this.image) {
log("Initiating DummyImageContainer");
DummyImageContainer.prototype.image = new Image();
var image = this.image;
DummyImageContainer.prototype.promise = new Promise(function(resolve, reject) {
image.onload = resolve;
image.onerror = reject;
image.src = smallImage();
if (image.complete === true) {
resolve(image);
}
});
}
}