mirror of https://github.com/toddmotto/echo.git
Arnaud JAEGERS
11 years ago
5 changed files with 24 additions and 12 deletions
@ -1,2 +1,2 @@
|
||||
/*! echo.js v1.6.0 | (c) 2014 @toddmotto | https://github.com/toddmotto/echo */ |
||||
!function(t,e){"function"==typeof define&&define.amd?define(function(){return e(t)}):"object"==typeof exports?module.exports=e:t.echo=e(t)}(this,function(t){"use strict";var e,n,o,r,c,i={},l=function(){},a=function(t,e){var n=t.getBoundingClientRect();return n.right>=e.l&&n.bottom>=e.t&&n.left<=e.r&&n.top<=e.b},d=function(){(r||!n)&&(clearTimeout(n),n=setTimeout(function(){i.render(),n=null},o))};return i.init=function(n){n=n||{};var a=n.offset||0,u=n.offsetVertical||a,f=n.offsetHorizontal||a,s=function(t,e){return parseInt(t||e,10)};e={t:s(n.offsetTop,u),b:s(n.offsetBottom,u),l:s(n.offsetLeft,f),r:s(n.offsetRight,f)},o=s(n.throttle,250),r=n.debounce!==!1,c=!!n.unload,l=n.callback||l,i.render(),document.addEventListener?(t.addEventListener("scroll",d,!1),t.addEventListener("load",d,!1)):(t.attachEvent("onscroll",d),t.attachEvent("onload",d))},i.render=function(){for(var n,o,r=document.querySelectorAll("img[data-echo]"),d=r.length,u={l:0-e.l,t:0-e.t,b:(t.innerHeight||document.documentElement.clientHeight)+e.b,r:(t.innerWidth||document.documentElement.clientWidth)+e.r},f=0;d>f;f++)o=r[f],a(o,u)?(c&&o.setAttribute("data-echo-placeholder",o.src),o.src=o.getAttribute("data-echo"),c||o.removeAttribute("data-echo"),l(o,"load")):c&&(n=o.getAttribute("data-echo-placeholder"))&&(o.src=n,o.removeAttribute("data-echo-placeholder"),l(o,"unload"));d||i.detach()},i.detach=function(){document.removeEventListener?t.removeEventListener("scroll",d):t.detachEvent("onscroll",d),clearTimeout(n)},i}); |
||||
!function(t,e){"function"==typeof define&&define.amd?define(function(){return e(t)}):"object"==typeof exports?module.exports=e:t.echo=e(t)}(this,function(t){"use strict";var e,n,o,r,c,i,a={},l=function(){},d=function(t,e){var n=t.getBoundingClientRect();return n.right>=e.l&&n.bottom>=e.t&&n.left<=e.r&&n.top<=e.b},u=function(){(r||!n)&&(clearTimeout(n),n=setTimeout(function(){a.render(),n=null},o))};return a.init=function(n){n=n||{};var d=n.offset||0,f=n.offsetVertical||d,s=n.offsetHorizontal||d,h=function(t,e){return parseInt(t||e,10)};e={t:h(n.offsetTop,f),b:h(n.offsetBottom,f),l:h(n.offsetLeft,s),r:h(n.offsetRight,s)},o=h(n.throttle,250),r=n.debounce!==!1,c=!!n.unload,l=n.callback||l,i=n.container||t,a.render(),document.addEventListener?(t.addEventListener("scroll",u,!1),t.addEventListener("load",u,!1)):(t.attachEvent("onscroll",u),t.attachEvent("onload",u))},a.render=function(){for(var t,n,o=document.querySelectorAll("img[data-echo]"),r=o.length,u={l:0-e.l,t:0-e.t,b:(i.innerHeight||i.clientHeight)+e.b,r:(i.innerWidth||i.clientWidth)+e.r},f=0;r>f;f++)n=o[f],d(n,u)?(c&&n.setAttribute("data-echo-placeholder",n.src),n.src=n.getAttribute("data-echo"),c||n.removeAttribute("data-echo"),l(n,"load")):c&&(t=n.getAttribute("data-echo-placeholder"))&&(n.src=t,n.removeAttribute("data-echo-placeholder"),l(n,"unload"));r||a.detach()},a.detach=function(){document.removeEventListener?t.removeEventListener("scroll",u):t.detachEvent("onscroll",u),clearTimeout(n)},a}); |
Loading…
Reference in new issue