Image lazy loader
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2 lines
886 B

/*! Echo v1.4.0 | (c) 2014 @toddmotto | MIT license | github.com/toddmotto/echo */
!function(a,b,c){"use strict";"function"==typeof define&&define.amd?define(c):"undefined"!=typeof module&&module.exports?module.exports=c():b[a]=c()}("Echo",this,function(){"use strict";function a(){var a,b,c,d=[],e=function(b){var c=b.getBoundingClientRect();return(c.top>=0&&c.left>=0&&c.top)<=(window.innerHeight||document.documentElement.clientHeight)+parseInt(a)},f=function(){for(var a=d.length;a--;){var b=d[a];e(b)&&(b.src=b.getAttribute("data-echo"),d.splice(a,1))}},g=function(){clearTimeout(c),c=setTimeout(f,b)},h=function(c){var e=document.querySelectorAll("[data-echo]"),f=c||{};a=f.offset||0,b=f.throttle||250;for(var h=0;h<e.length;h++)d.push(e[h]);g(),document.addEventListener?window.addEventListener("scroll",g,!1):window.attachEvent("onscroll",g)};return{init:h,render:g}}return a});