Permalink
Browse files

Do not use splice() when in a loop

  • Loading branch information...
1 parent 08bc946 commit ddfde16139b4e442c3357133e58186151845586f vvo committed Mar 5, 2012
Showing with 9 additions and 9 deletions.
  1. +6 −6 LL.js
  2. +2 −2 LL.min.js
  3. +1 −1 package.json
View
12 LL.js
@@ -37,12 +37,12 @@
if (img.getBoundingClientRect().top < winH + 200) {
img.src = img.getAttribute(lazyAttr);
img.removeAttribute(lazyAttr);
- imgs.splice(index, 1);
- // img shown
- return true;
+ // we do not use splice() as we could be in the checkImages's for loop
+ imgs[index] = null;
+
+ return true; // img shown
} else {
- // img to be shown
- return false;
+ return false; // img to be shown
}
}
@@ -75,7 +75,7 @@
var img = imgs[current];
// if showIfVisible is false, it means we have some waiting images to be
// shown
- if(img !== undefined && showIfVisible(img, current) === false) {
+ if(img !== null && showIfVisible(img, current) === false) {
allImagesDone = false;
}
}
View

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

Oops, something went wrong.
View
@@ -1,7 +1,7 @@
{
"name": "LL",
"description": "Lazy load my friend",
- "version": "0.5.1",
+ "version": "0.5.2",
"repository": {
"type": "git",
"url": "http://github.com/fasterize/LL.git"

0 comments on commit ddfde16

Please sign in to comment.