mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
* Cancel old timer, editing pr for $4139
This commit is contained in:
committed by
John-David Dalton
parent
3ae8f23bff
commit
fe7da41956
@@ -78,7 +78,7 @@ function debounce(func, wait, options) {
|
||||
// Bypass `requestAnimationFrame` by explicitly setting `wait=0`.
|
||||
const useRAF = (!wait && wait !== 0 && typeof root.requestAnimationFrame === 'function')
|
||||
|
||||
if (typeof func != 'function') {
|
||||
if (typeof func !== 'function') {
|
||||
throw new TypeError('Expected a function')
|
||||
}
|
||||
wait = +wait || 0
|
||||
@@ -101,6 +101,7 @@ function debounce(func, wait, options) {
|
||||
|
||||
function startTimer(pendingFunc, wait) {
|
||||
if (useRAF) {
|
||||
root.cancelAnimationFrame(timerId);
|
||||
return root.requestAnimationFrame(pendingFunc)
|
||||
}
|
||||
return setTimeout(pendingFunc, wait)
|
||||
|
||||
Reference in New Issue
Block a user