Update vendors.

Former-commit-id: e88301bddf23f177a2d14f2c729877eaede022e5
This commit is contained in:
John-David Dalton
2012-10-09 20:11:57 -07:00
parent d1178defe0
commit 9086d189b9
8 changed files with 370 additions and 498 deletions

File diff suppressed because one or more lines are too long

View File

@@ -622,25 +622,25 @@
// Returns a function, that, when invoked, will only be triggered at most once
// during a given window of time.
_.throttle = function(func, wait) {
var context, args, timeout, throttling, more, result;
var whenDone = _.debounce(function(){ more = throttling = false; }, wait);
var context, args, timeout, result;
var previous = 0;
var later = function() {
previous = new Date;
timeout = null;
result = func.apply(context, args);
};
return function() {
context = this; args = arguments;
var later = function() {
timeout = null;
if (more) {
result = func.apply(context, args);
}
whenDone();
};
if (!timeout) timeout = setTimeout(later, wait);
if (throttling) {
more = true;
} else {
throttling = true;
var now = new Date;
var remaining = wait - (now - previous);
context = this;
args = arguments;
if (remaining <= 0) {
clearTimeout(timeout);
previous = now;
result = func.apply(context, args);
} else if (!timeout) {
timeout = setTimeout(later, remaining);
}
whenDone();
return result;
};
};