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