mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 23:37:49 +00:00
Clear timeoutId if func is called in _.debounce.
This commit is contained in:
@@ -5737,21 +5737,22 @@
|
||||
}
|
||||
lastCalled = stamp;
|
||||
result = func.apply(thisArg, args);
|
||||
args = thisArg = null;
|
||||
}
|
||||
else if (!maxTimeoutId) {
|
||||
maxTimeoutId = setTimeout(maxDelayed, remaining);
|
||||
}
|
||||
}
|
||||
if (!timeoutId && wait !== maxWait) {
|
||||
if (isCalled & timeoutId) {
|
||||
timeoutId = clearTimeout(timeoutId);
|
||||
}
|
||||
else if (!timeoutId && wait !== maxWait) {
|
||||
timeoutId = setTimeout(delayed, wait);
|
||||
}
|
||||
if (leadingCall) {
|
||||
isCalled = true;
|
||||
result = func.apply(thisArg, args);
|
||||
}
|
||||
if (isCalled && !timeoutId && !maxTimeoutId) {
|
||||
args = thisArg = null;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user