diff --git a/src/yui-throttle/js/throttle.js b/src/yui-throttle/js/throttle.js index 2be24a932a3..8a7cb942e09 100644 --- a/src/yui-throttle/js/throttle.js +++ b/src/yui-throttle/js/throttle.js @@ -29,6 +29,8 @@ to the `Y` object and is documente * @since 3.1.0 */ Y.throttle = function(fn, ms) { + var last; + ms = (ms) ? ms : (Y.config.throttleTime || 150); if (ms === -1) { @@ -37,11 +39,10 @@ Y.throttle = function(fn, ms) { }; } - var last = Y.Lang.now(); - return function() { var now = Y.Lang.now(); - if (now - last > ms) { + + if (!last || (now - last > ms)) { last = now; fn.apply(this, arguments); }