/*! Echo v1.5.0 | (c) 2014 @toddmotto | MIT license | github.com/toddmotto/echo */ window.Echo = (function (global, document, undefined) { 'use strict'; /** * callback - initialized to a no-op so that no validations on it's presence need to be made * @type {Function} */ var callback = function(){}; /** * offset, throttle, poll, unload, debounce vars */ var offset, throttle, poll, unload, debounce; /** * _inView * @private * @param {Element} element Image element * @returns {Boolean} Is element in viewport */ var _inView = function (element, view) { var box = element.getBoundingClientRect(); return (box.right >= view.l && box.bottom >= view.t && box.left <= view.r && box.top <= view.b); }; /** * _pollImages Loop through the images if present * or remove all event listeners * @private */ var _pollImages = function () { var src, i, elem, view, nodes = document.querySelectorAll('img[data-echo]'), length = nodes.length; poll = null; view = { l: 0 - offset.l, t: 0 - offset.t, b: (window.innerHeight || document.documentElement.clientHeight) + offset.b, r: (window.innerWidth || document.documentElement.clientWidth) + offset.r }; for(i=0; i