Created
November 4, 2010 19:24
-
-
Save robv/663023 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function() { | |
$.fn.imagesLoaded = function(callback){ | |
var elems = this.filter('img'), | |
len = elems.length; | |
elems.bind('load',function(){ | |
if (--len <= 0){ callback.call(elems,this); } | |
}).each(function(){ | |
// cached images don't fire load sometimes, so we reset src. | |
if (this.complete || this.complete === undefined){ | |
var src = this.src; | |
// webkit hack from http://groups.google.com/group/jquery-dev/browse_thread/thread/eee6ab7b2da50e1f | |
// data uri bypasses webkit log warning (thx doug jones) | |
this.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw=="; | |
this.src = src; | |
} | |
}); | |
return this; | |
}; | |
$('#image').hide(); | |
$('#loader').show(); | |
$('#image').imagesLoaded(function(){ | |
$(this).show(); | |
$('#loader').hide(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment