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