From f56d3284579b2463c7e2989cae7702800f49ef14 Mon Sep 17 00:00:00 2001 From: Roshan Bhalla Date: Fri, 31 Jan 2014 12:14:44 +0000 Subject: [PATCH] Fix throttle behaviour --- dist/echo.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/dist/echo.js b/dist/echo.js index ae82751..db7a7ac 100644 --- a/dist/echo.js +++ b/dist/echo.js @@ -12,7 +12,7 @@ window.Echo = (function (global, document, undefined) { /** * offset, throttle, poll vars */ - var offset, throttle, poll; + var offset, throttle, poll, finalPoll; /** * _inView @@ -50,6 +50,10 @@ window.Echo = (function (global, document, undefined) { } clearTimeout(poll); } + + poll = setTimeout(function(){ + poll = null; + }, throttle); }; /** @@ -57,8 +61,12 @@ window.Echo = (function (global, document, undefined) { * @private */ var _throttle = function () { - clearTimeout(poll); - poll = setTimeout(_pollImages, throttle); + if (!poll) { + _pollImages(); + } else { + clearTimeout(finalPoll); + finalPoll = setTimeout (_pollImages, throttle); + } }; /**