Browse Source

Remove element from array once the src is set

I think this is what was intended.  Elements are removed from `store` once the src is set to the data-echo attribute.
pull/10/head
Benjamin J DeLong 11 years ago
parent
commit
8009c6c017
  1. 7
      src/echo.js

7
src/echo.js

@ -10,19 +10,18 @@ window.Echo = (function (window, document, undefined) {
}; };
var _pollImages = function () { var _pollImages = function () {
for (var i = 0; i < store.length; i++) { for (var i = 0, len = store.length; i < len; i++) {
var self = store[i]; var self = store[i];
if (_inView(self)) { if (_inView(self)) {
self.src = self.getAttribute('data-echo'); self.src = self.getAttribute('data-echo');
if ([].indexOf && [].slice.call(store).indexOf(self) !== -1) { store.splice(i, 1);
[].slice.call(store).splice(i, 1);
}
} }
} }
}; };
var init = function () { var init = function () {
store = document.querySelectorAll('[data-echo]'); store = document.querySelectorAll('[data-echo]');
store = [].slice.call(store);
_pollImages(); _pollImages();
window.onscroll = _pollImages; window.onscroll = _pollImages;
}; };

Loading…
Cancel
Save