Skip to content

Instantly share code, notes, and snippets.

@diago
Created January 15, 2010 13:54
Show Gist options
  • Save diago/278074 to your computer and use it in GitHub Desktop.
Save diago/278074 to your computer and use it in GitHub Desktop.
(function(){
function loaded(elem){
var elem = $(elem);
var images = elem.retrieve('loadingImages', elem.select('img'));
var loading = images.find(function(elem){
return !elem.complete;
});
if(loading) return loaded.delay(.3, elem);
else {elem.fire('images:loaded'); elem.store('loadingImages', undefined);}
return elem;
};
Element.addMethods({
loaded: loaded
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment