bind load & error to img; for Firefox fix #191

This commit is contained in:
David DeSandro
2015-10-27 16:11:39 -04:00
parent fcf5e58f82
commit bcbb8caf16

View File

@@ -245,10 +245,13 @@ function makeArray( obj ) {
}
// If none of the checks above matched, simulate loading on detached element.
var proxyImage = new Image();
eventie.bind( proxyImage, 'load', this );
eventie.bind( proxyImage, 'error', this );
proxyImage.src = this.img.src;
this.proxyImage = new Image();
eventie.bind( this.proxyImage, 'load', this );
eventie.bind( this.proxyImage, 'error', this );
// bind to image as well for Firefox. #191
eventie.bind( this.img, 'load', this );
eventie.bind( this.img, 'error', this );
this.proxyImage.src = this.img.src;
};
LoadingImage.prototype.confirm = function( isLoaded, message ) {
@@ -268,18 +271,19 @@ function makeArray( obj ) {
LoadingImage.prototype.onload = function( event ) {
this.confirm( true, 'onload' );
this.unbindProxyEvents( event );
this.unbindEvents();
};
LoadingImage.prototype.onerror = function( event ) {
debugger;
this.confirm( false, 'onerror' );
this.unbindProxyEvents( event );
this.unbindEvents();
};
LoadingImage.prototype.unbindProxyEvents = function( event ) {
eventie.unbind( event.target, 'load', this );
eventie.unbind( event.target, 'error', this );
LoadingImage.prototype.unbindEvents = function() {
eventie.unbind( this.proxyImage, 'load', this );
eventie.unbind( this.proxyImage, 'error', this );
eventie.unbind( this.img, 'load', this );
eventie.unbind( this.img, 'error', this );
};
// ----- ----- //