Skip to content

Commit

Permalink
Fix image.useCached function when width is not set in Chrome in very …
Browse files Browse the repository at this point in the history
…fast environment
  • Loading branch information
nyroDev committed Nov 29, 2013
1 parent 0501ddd commit 51288c5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion imagesloaded.js
Expand Up @@ -228,7 +228,15 @@ function defineImagesLoaded( EventEmitter, eventie ) {

LoadingImage.prototype.useCached = function( cached ) {
if ( cached.isConfirmed ) {
this.confirm( cached.isLoaded, 'cached was confirmed' );
var _this = this,
checkWidth = function() {
if (_this.img.naturalWidth !== 0) {
_this.confirm( cached.isLoaded, 'cached was confirmed' );
} else {
setTimeout(checkWidth, 2);
}
};
checkWidth();
} else {
var _this = this;
cached.on( 'confirm', function( image ) {
Expand Down

0 comments on commit 51288c5

Please sign in to comment.