mirror of https://github.com/toddmotto/echo.git
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
1.1 KiB
2 lines
1.1 KiB
/*! Echo v1.5.0 | (c) 2014 @toddmotto | MIT license | github.com/toddmotto/echo */ |
|
window.Echo=function(a,b){"use strict";var c,d,e,f=[],g=function(){},h=b.compareDocumentPosition?function(a,b){return a.contains(b)}:function(a,b){return 16&a.compareDocumentPosition(b)},i=function(a){var d=a.getBoundingClientRect();return(d.top>=0&&d.left>=0&&d.top)<=(window.innerHeight||b.documentElement.clientHeight)+c},j=function(){var c=f.length;if(c>0)for(var d=0;c>d;d++){var j=f[d];j&&h(b.documentElement,j)&&i(j)&&(j.src=j.getAttribute("data-echo"),g(j),f.splice(d,1),c=f.length,d--)}else b.removeEventListener?a.removeEventListener("scroll",k):a.detachEvent("onscroll",k),clearTimeout(e)},k=function(){clearTimeout(e),e=setTimeout(j,d)},l=function(e){var h=b.querySelectorAll("[data-echo]"),i=e||{};c=parseInt(i.offset||0),d=parseInt(i.throttle||250),g=i.callback||g;for(var l=0;l<h.length;l++)f.push(h[l]);j(),b.addEventListener?(a.addEventListener("scroll",k,!1),a.addEventListener("load",k,!1)):(a.attachEvent("onscroll",k),a.attachEvent("onload",k))};return{init:l,render:j}}(this,document); |