Skip to content

Commit

Permalink
filter for images as well; v1.0.3
Browse files Browse the repository at this point in the history
move other comments for better uglification

So it doesn't break for people switching from @paulirish's old version.
  • Loading branch information
desandro committed Sep 1, 2011
1 parent 566f926 commit e8117ce
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
8 changes: 7 additions & 1 deletion README.markdown
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,6 @@
# imagesLoaded # 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 ```js
$('#my-container').imagesLoaded( function( $images ) { $('#my-container').imagesLoaded( function( $images ) {
Expand All @@ -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/) [**See demo**](http://desandro.github.com/imagesloaded/)


Used in [Masonry](http://desandro.masonry.com/) and [Isotope](http://isotope.metafizzy.co/). Used in [Masonry](http://desandro.masonry.com/) and [Isotope](http://isotope.metafizzy.co/).
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ <h1>jQuery imagesLoaded</h1>
}); });


$('#all-done').click(function(){ $('#all-done').click(function(){
$holder.imagesLoaded(function( $images ){ $holder.find('img').imagesLoaded(function( $images ){
alert( $images.length + ' images have been loaded.' ); alert( $images.length + ' images have been loaded.' );
}); });
}); });
Expand Down
20 changes: 12 additions & 8 deletions jquery.imagesloaded.js
Original file line number Original file line Diff line number Diff line change
@@ -1,21 +1,25 @@
/*! /*!
* jQuery imagesLoaded plugin v1.0.2 * jQuery imagesLoaded plugin v1.0.3
* http://github.com/desandro/imagesloaded * http://github.com/desandro/imagesloaded
* *
* MIT License. by Paul Irish et al. * MIT License. by Paul Irish et al.
*/ */


// $('#my-container').imagesLoaded(myFunction) (function($, undefined) {
// execute a callback when all images have loaded.
// needed because .load() doesn't work on cached images


// callback function gets image collection as argument // $('#my-container').imagesLoaded(myFunction)
// `this` is the container // 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 ) { $.fn.imagesLoaded = function( callback ) {
var $this = this, var $this = this,
$images = $this.find('img'), $images = $this.find('img').add( $this.filter('img') ),
len = $images.length, len = $images.length,
blank = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw=='; blank = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==';


Expand Down

0 comments on commit e8117ce

Please sign in to comment.