Browse Source

Fix throttle behaviour

pull/35/head
Roshan Bhalla 11 years ago
parent
commit
f56d328457
  1. 14
      dist/echo.js

14
dist/echo.js vendored

@ -12,7 +12,7 @@ window.Echo = (function (global, document, undefined) {
/** /**
* offset, throttle, poll vars * offset, throttle, poll vars
*/ */
var offset, throttle, poll; var offset, throttle, poll, finalPoll;
/** /**
* _inView * _inView
@ -50,6 +50,10 @@ window.Echo = (function (global, document, undefined) {
} }
clearTimeout(poll); clearTimeout(poll);
} }
poll = setTimeout(function(){
poll = null;
}, throttle);
}; };
/** /**
@ -57,8 +61,12 @@ window.Echo = (function (global, document, undefined) {
* @private * @private
*/ */
var _throttle = function () { var _throttle = function () {
clearTimeout(poll); if (!poll) {
poll = setTimeout(_pollImages, throttle); _pollImages();
} else {
clearTimeout(finalPoll);
finalPoll = setTimeout (_pollImages, throttle);
}
}; };
/** /**

Loading…
Cancel
Save