Browse Source

fix issue #83 (Image Inside a Scrollable div Would not be Loaded)

pull/84/head
ethonchan 10 years ago
parent
commit
86e01ee8bb
  1. 39
      src/echo.js

39
src/echo.js

@ -1,20 +1,12 @@
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(function() {
return factory(root);
});
} else if (typeof exports === 'object') {
module.exports = factory;
} else {
root.echo = factory(root);
}
})(this, function (root) {
(function() {
'use strict';
var echo = {};
var _global = this || (0,eval)('this');
var root = {};
var callback = function () {};
var callback = function () {
};
var offset, poll, delay, useDebounce, unload;
@ -32,11 +24,11 @@
};
var debounceOrThrottle = function () {
if(!useDebounce && !!poll) {
if (!useDebounce && !!poll) {
return;
}
clearTimeout(poll);
poll = setTimeout(function(){
poll = setTimeout(function () {
echo.render();
poll = null;
}, delay);
@ -44,7 +36,7 @@
echo.init = function (opts) {
opts = opts || {};
root = opts.viewport || this || (0,eval)('this');
root = opts.viewport || _global;
var offsetAll = opts.offset || 0;
var offsetVertical = opts.offsetVertical || offsetAll;
var offsetHorizontal = opts.offsetHorizontal || offsetAll;
@ -78,8 +70,8 @@
var view = {
l: 0 - offset.l,
t: 0 - offset.t,
b: (root.innerHeight || document.documentElement.clientHeight) + offset.b,
r: (root.innerWidth || document.documentElement.clientWidth) + offset.r
b: (root.innerHeight || root.clientHeight) + offset.b,
r: (root.innerWidth || root.clientWidth) + offset.r
};
for (var i = 0; i < length; i++) {
elem = nodes[i];
@ -130,6 +122,13 @@
clearTimeout(poll);
};
if ((typeof module !== "undefined" && module !== null) && module.exports) {
module.exports = echo;
} else if (typeof define === 'function') {
define(function() {
return echo;
});
});
} else {
root.echo = echo;
}
}());
Loading…
Cancel
Save