1
0
mirror of synced 2025-02-16 20:13:16 +03:00

Pass along arguments sent to debounce

Signed-off-by: Igor Vaynberg <igor.vaynberg@gmail.com>
This commit is contained in:
Kyle Gibson 2012-08-27 12:09:47 -04:00 committed by Igor Vaynberg
parent 9003c2dd18
commit de867bbba1

View File

@ -195,13 +195,18 @@
*
* @param quietMillis number of milliseconds to wait before invoking fn
* @param fn function to be debounced
* @param thisobj object to be used as this reference within fn
* @return debounced version of fn
*/
function debounce(quietMillis, fn) {
function debounce(quietMillis, fn, thisobj) {
thisobj = thisobj || undefined;
var timeout;
return function () {
var args = arguments;
window.clearTimeout(timeout);
timeout = window.setTimeout(fn, quietMillis);
timeout = window.setTimeout(function() {
fn.apply(thisobj, args);
}, quietMillis);
};
}