mirror of
https://github.com/desandro/imagesloaded.git
synced 2026-04-17 03:00:06 -04:00
bind load & error to img; for Firefox fix #191
This commit is contained in:
@@ -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 );
|
||||
};
|
||||
|
||||
// ----- ----- //
|
||||
|
||||
Reference in New Issue
Block a user