Browse Source

Echo v1.1.0, minor event bind enhancement

pull/4/head v1.1.0
Todd Motto 12 years ago
parent
commit
4f173e6fda
  1. 24
      dist/echo.js
  2. 4
      dist/echo.min.js
  3. 2
      package.json
  4. 22
      src/echo.js

24
dist/echo.js vendored

@ -1,6 +1,6 @@
/*!
* Echo
* @version 1.0.0
* @version 1.1.0
* @author Todd Motto http://toddmotto.com
* Project: https://github.com/toddmotto/echo
*
@ -16,8 +16,6 @@ window.echo = (function (window, document) {
*/
var Echo = function (elem) {
this.elem = elem;
this.render();
this.listen();
};
/*
@ -70,16 +68,6 @@ window.echo = (function (window, document) {
Echo.prototype = {
init : function () {
echoStore.push(this.elem);
},
render : function () {
if (document.addEventListener) {
document.addEventListener('DOMContentLoaded', echoImages, false);
} else {
window.onload = echoImages;
}
},
listen : function () {
window.onscroll = echoImages;
}
};
@ -91,4 +79,14 @@ window.echo = (function (window, document) {
new Echo(lazyImgs[i]).init();
}
/*
* Bind the events
*/
if (document.addEventListener) {
document.addEventListener('DOMContentLoaded', echoImages, false);
} else {
window.onload = echoImages;
}
window.onscroll = echoImages;
})(window, document);

4
dist/echo.min.js vendored

@ -1,10 +1,10 @@
/*!
* Echo
* @version 1.0.0
* @version 1.1.0
* @author Todd Motto http://toddmotto.com
* Project: https://github.com/toddmotto/echo
*
* Raw JavaScript lazy-loading images with HTML5 data-* attributes.
* Copyright 2013. MIT licensed.
*/
window.echo=function(a,b){"use strict";var c=function(a){this.elem=a,this.render(),this.listen()},d=[],e=function(c){var d=c.getBoundingClientRect();return(d.top>=0&&d.left>=0&&d.top)<=(a.innerHeight||b.documentElement.clientHeight)},f=function(a,b){a.src=a.getAttribute("data-echo"),b&&b()},g=function(a,b){-1!==d.indexOf(a)&&d.splice(b,1)},h=function(){for(var a=0;a<d.length;a++){var b=d[a];e(b)&&f(b,g(b,a))}};c.prototype={init:function(){d.push(this.elem)},render:function(){b.addEventListener?b.addEventListener("DOMContentLoaded",h,!1):a.onload=h},listen:function(){a.onscroll=h}};for(var i=b.querySelectorAll("img[data-echo]"),j=0;j<i.length;j++)new c(i[j]).init()}(window,document);
window.echo=function(a,b){"use strict";var c=function(a){this.elem=a},d=[],e=function(c){var d=c.getBoundingClientRect();return(d.top>=0&&d.left>=0&&d.top)<=(a.innerHeight||b.documentElement.clientHeight)},f=function(a,b){a.src=a.getAttribute("data-echo"),b&&b()},g=function(a,b){-1!==d.indexOf(a)&&d.splice(b,1)},h=function(){for(var a=0;a<d.length;a++){var b=d[a];e(b)&&f(b,g(b,a))}};c.prototype={init:function(){d.push(this.elem)}};for(var i=b.querySelectorAll("img[data-echo]"),j=0;j<i.length;j++)new c(i[j]).init();b.addEventListener?b.addEventListener("DOMContentLoaded",h,!1):a.onload=h,a.onscroll=h}(window,document);

2
package.json

@ -11,7 +11,7 @@
{ "type": "MIT" }
],
"year" : "2013",
"version": "1.0.0",
"version": "1.1.0",
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-concat": "~0.3.0",

22
src/echo.js

@ -7,8 +7,6 @@ window.echo = (function (window, document) {
*/
var Echo = function (elem) {
this.elem = elem;
this.render();
this.listen();
};
/*
@ -61,16 +59,6 @@ window.echo = (function (window, document) {
Echo.prototype = {
init : function () {
echoStore.push(this.elem);
},
render : function () {
if (document.addEventListener) {
document.addEventListener('DOMContentLoaded', echoImages, false);
} else {
window.onload = echoImages;
}
},
listen : function () {
window.onscroll = echoImages;
}
};
@ -82,4 +70,14 @@ window.echo = (function (window, document) {
new Echo(lazyImgs[i]).init();
}
/*
* Bind the events
*/
if (document.addEventListener) {
document.addEventListener('DOMContentLoaded', echoImages, false);
} else {
window.onload = echoImages;
}
window.onscroll = echoImages;
})(window, document);
Loading…
Cancel
Save