Permalink
Browse files

filter for images as well; v1.0.3

move other comments for better uglification

So it doesn't break for people switching from @paulirish's old version.
  • Loading branch information...
1 parent 566f926 commit e8117cec1c0619c5f7b99fc5e4daf0f1f67706c3 @desandro committed Sep 1, 2011
Showing with 20 additions and 10 deletions.
  1. +7 −1 README.markdown
  2. +1 −1 index.html
  3. +12 −8 jquery.imagesloaded.js
View
@@ -1,6 +1,6 @@
# imagesLoaded
-A small jQuery plugin that triggers a callback after all the child images in a parent element have been loaded. Because you can't do `.load()` on images.
+A small jQuery plugin that triggers a callback after all the selected/child images have been loaded. Because you can't do `.load()` on cached images.
```js
$('#my-container').imagesLoaded( function( $images ) {
@@ -9,6 +9,12 @@ $('#my-container').imagesLoaded( function( $images ) {
});
```
+You can call `imagesLoaded` on a set of images as well.
+
+```js
+$('.article img').imagesLoaded( myFunction );
+```
+
[**See demo**](http://desandro.github.com/imagesloaded/)
Used in [Masonry](http://desandro.masonry.com/) and [Isotope](http://isotope.metafizzy.co/).
View
@@ -88,7 +88,7 @@
});
$('#all-done').click(function(){
- $holder.imagesLoaded(function( $images ){
+ $holder.find('img').imagesLoaded(function( $images ){
alert( $images.length + ' images have been loaded.' );
});
});
@@ -1,21 +1,25 @@
/*!
- * jQuery imagesLoaded plugin v1.0.2
+ * jQuery imagesLoaded plugin v1.0.3
* http://github.com/desandro/imagesloaded
*
* MIT License. by Paul Irish et al.
*/
-// $('#my-container').imagesLoaded(myFunction)
-// execute a callback when all images have loaded.
-// needed because .load() doesn't work on cached images
+(function($, undefined) {
-// callback function gets image collection as argument
-// `this` is the container
+ // $('#my-container').imagesLoaded(myFunction)
+ // or
+ // $('img').imagesLoaded(myFunction)
+
+ // execute a callback when all images have loaded.
+ // needed because .load() doesn't work on cached images
+
+ // callback function gets image collection as argument
+ // `this` is the container
-(function($, undefined) {
$.fn.imagesLoaded = function( callback ) {
var $this = this,
- $images = $this.find('img'),
+ $images = $this.find('img').add( $this.filter('img') ),
len = $images.length,
blank = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==';

0 comments on commit e8117ce

Please sign in to comment.