Browse Source

Added IE8 support, hooray!

pull/4/head
Todd Motto 11 years ago
parent
commit
dd712f9364
  1. 2
      README.md
  2. 4
      dist/echo.js
  3. 2
      dist/echo.min.js
  4. 4
      src/echo.js

2
README.md

@ -1,6 +1,6 @@
# Echo [![Build Status](https://travis-ci.org/toddmotto/echo.png)](https://travis-ci.org/toddmotto/echo) # Echo [![Build Status](https://travis-ci.org/toddmotto/echo.png)](https://travis-ci.org/toddmotto/echo)
Echo is a standalone JavaScript lazy-loading image tool. Echo is fast, less than 1KB and uses HTML5 data-* attributes. Echo is a standalone JavaScript lazy-loading image tool. Echo is fast, less than 1KB and uses HTML5 data-* attributes. Echo works in IE8+.
```html ```html
<img src="img/blank.gif" alt="Photo" data-echo="img/photo.jpg"> <img src="img/blank.gif" alt="Photo" data-echo="img/photo.jpg">

4
dist/echo.js vendored

@ -21,7 +21,7 @@ window.Echo = (function (window, document, undefined) {
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 (store.indexOf(self) !== -1) { if ([].indexOf && store.indexOf(self) !== -1) {
store.splice(i, 1); store.splice(i, 1);
} }
} }
@ -29,7 +29,7 @@ window.Echo = (function (window, document, undefined) {
}; };
var init = function () { var init = function () {
store = [].slice.call(document.querySelectorAll('[data-echo]')); store = document.querySelectorAll('[data-echo]');
_pollImages(); _pollImages();
window.onscroll = _pollImages; window.onscroll = _pollImages;
}; };

2
dist/echo.min.js vendored

@ -5,4 +5,4 @@
* by Todd Motto: http://toddmotto.com * by Todd Motto: http://toddmotto.com
* Copyright. MIT licensed. * Copyright. MIT licensed.
*/ */
window.Echo=function(a,b){"use strict";var c,d=function(c){var d=c.getBoundingClientRect();return(d.top>=0&&d.left>=0&&d.top)<=(a.innerHeight||b.documentElement.clientHeight)},e=function(){for(var a=0;a<c.length;a++){var b=c[a];d(b)&&(b.src=b.getAttribute("data-echo"),-1!==c.indexOf(b)&&c.splice(a,1))}},f=function(){c=[].slice.call(b.querySelectorAll("[data-echo]")),e(),a.onscroll=e};return{init:f}}(window,document); window.Echo=function(a,b){"use strict";var c,d=function(c){var d=c.getBoundingClientRect();return(d.top>=0&&d.left>=0&&d.top)<=(a.innerHeight||b.documentElement.clientHeight)},e=function(){for(var a=0;a<c.length;a++){var b=c[a];d(b)&&(b.src=b.getAttribute("data-echo"),[].indexOf&&-1!==c.indexOf(b)&&c.splice(a,1))}},f=function(){c=b.querySelectorAll("[data-echo]"),e(),a.onscroll=e};return{init:f}}(window,document);

4
src/echo.js

@ -14,7 +14,7 @@ window.Echo = (function (window, document, undefined) {
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 (store.indexOf(self) !== -1) { if ([].indexOf && store.indexOf(self) !== -1) {
store.splice(i, 1); store.splice(i, 1);
} }
} }
@ -22,7 +22,7 @@ window.Echo = (function (window, document, undefined) {
}; };
var init = function () { var init = function () {
store = [].slice.call(document.querySelectorAll('[data-echo]')); store = document.querySelectorAll('[data-echo]');
_pollImages(); _pollImages();
window.onscroll = _pollImages; window.onscroll = _pollImages;
}; };

Loading…
Cancel
Save