Skip to content

Commit

Permalink
Fix number of elements left for the first call of callback.
Browse files Browse the repository at this point in the history
  • Loading branch information
tuupola committed Jan 25, 2012
1 parent 4fb4e8e commit 2acf0ce
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions jquery.lazyload.js
Expand Up @@ -60,7 +60,7 @@
});
});
}

this.each(function() {
var self = this;
var $self = $(self);
Expand All @@ -77,20 +77,20 @@
.attr("src", $self.data(settings.data_attribute))
[settings.effect](settings.effectspeed);
self.loaded = true;

/* Remove image from array so it is not looped next time. */
var temp = $.grep(elements, function(element) {
return !element.loaded;
});
elements = $(temp);

if (settings.callback) {
var elements_left = elements.length - 1;
var elements_left = elements.length;
settings.callback.call(self, elements_left, settings);
}
})
.attr("src", $self.data(settings.data_attribute));
};

/* Remove image from array so it is not looped next time. */
var temp = $.grep(elements, function(element) {
return !element.loaded;
});
elements = $(temp);

};
});

/* When wanted event is triggered load original image */
Expand Down

0 comments on commit 2acf0ce

Please sign in to comment.