Permalink
Browse files

src : imagesLoaded : unbind loading fn once its called

  • Loading branch information...
desandro committed May 26, 2011
1 parent 7295e6e commit e26f87817bfadb8bc5234d75c96f8f97a0cd3fa7
Showing with 11 additions and 9 deletions.
  1. +9 −7 jquery.masonry.js
  2. +2 −2 jquery.masonry.min.js
View
@@ -1,5 +1,5 @@
/**
- * jQuery Masonry v2.0.110524
+ * jQuery Masonry v2.0.110526
* A dynamic layout plugin for jQuery
* The flip-side of CSS Floats
* http://masonry.desandro.com
@@ -383,19 +383,21 @@
var elems = this.find('img'),
len = elems.length,
blank = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==",
- _this = this;
+ _this = this,
+ loadImage = function(){
+ if ( --len <= 0 && this.src !== blank ) {
+ callback.call( _this );
+ elems.unbind( 'load', loadImage )
+ }
+ };
// if no images, trigger immediately
if ( !len ) {
callback.call( this );
return this;
}
- elems.bind('load', function() {
- if ( --len <= 0 && this.src !== blank ) {
- callback.call( _this );
- }
- }).each(function(){
+ elems.bind( 'load', loadImage ).each(function(){
// cached images don't fire load sometimes, so we reset src.
if (this.complete || this.complete === undefined){
var src = this.src;
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit e26f878

Please sign in to comment.