Ox.ImageElement: handle image error, use new LoadingScreen (start/stop)
This commit is contained in:
parent
94a18a2711
commit
1f926c83ea
1 changed files with 10 additions and 2 deletions
|
@ -32,6 +32,7 @@ Ox.ImageElement = function(options, self) {
|
||||||
width: self.options.width,
|
width: self.options.width,
|
||||||
height: self.options.height
|
height: self.options.height
|
||||||
})
|
})
|
||||||
|
.start()
|
||||||
.appendTo(that);
|
.appendTo(that);
|
||||||
|
|
||||||
loadImage();
|
loadImage();
|
||||||
|
@ -42,7 +43,10 @@ Ox.ImageElement = function(options, self) {
|
||||||
self.$image.off({load: showImage}).remove();
|
self.$image.off({load: showImage}).remove();
|
||||||
}
|
}
|
||||||
self.$image = $('<img>')
|
self.$image = $('<img>')
|
||||||
.one({load: showImage})
|
.one({
|
||||||
|
error: stopLoading,
|
||||||
|
load: showImage
|
||||||
|
})
|
||||||
.attr({src: self.options.src});
|
.attr({src: self.options.src});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,10 +64,14 @@ Ox.ImageElement = function(options, self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function showImage() {
|
function showImage() {
|
||||||
self.$screen.remove();
|
self.$screen.stop().remove();
|
||||||
self.$image.appendTo(that);
|
self.$image.appendTo(that);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function stopLoading() {
|
||||||
|
self.$screen.stop();
|
||||||
|
}
|
||||||
|
|
||||||
that.css = function(css) {
|
that.css = function(css) {
|
||||||
that.$element.css(css);
|
that.$element.css(css);
|
||||||
self.$screen && self.$screen.css(css);
|
self.$screen && self.$screen.css(css);
|
||||||
|
|
Loading…
Reference in a new issue