Skip to content

Commit

Permalink
Merge branch 'fix-loop-order' of https://github.com/oncletom/Imager.js
Browse files Browse the repository at this point in the history
…into oncletom-fix-loop-order
  • Loading branch information
Integralist committed Dec 19, 2013
2 parents 8c3de13 + a38cc7a commit df0acfa
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions Imager.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
new_collection = [];

for (; i < length; i++) {
new_collection[i] = callbackEach(collection[i]);
new_collection[i] = callbackEach(collection[i], i);
}

return new_collection;
Expand Down Expand Up @@ -183,23 +183,19 @@
};

Imager.prototype.changeDivsToEmptyImages = function(){
var divs = this.divs,
i = divs.length,
element;

while (i--) {
element = divs[i];
var self = this;

if (this.lazyload) {
if (this.isThisElementOnScreen(element)) {
this.divs[i] = this.createGif(element);
applyEach(this.divs, function(element, i){
if (self.lazyload) {
if (self.isThisElementOnScreen(element)) {
self.divs[i] = self.createGif(element);
} else {
this.imagesOffScreen.push(element);
self.imagesOffScreen.push(element);
}
} else {
this.divs[i] = this.createGif(element);
self.divs[i] = self.createGif(element);
}
}
});

if (this.initialized) {
this.checkImagesNeedReplacing(this.divs);
Expand All @@ -223,14 +219,14 @@
};

Imager.prototype.checkImagesNeedReplacing = function (images) {
var i = images.length;
var self = this;

if (!this.isResizing) {
this.isResizing = true;

while (i--) {
this.replaceImagesBasedOnScreenDimensions(images[i]);
}
applyEach(images, function(image){
self.replaceImagesBasedOnScreenDimensions(image);
});

this.isResizing = false;
}
Expand Down

0 comments on commit df0acfa

Please sign in to comment.