Cancel old timer, editing pr #4139 (#4187)

* Cancel old timer, editing pr for $4139
This commit is contained in:
moonformeli
2019-02-12 15:50:11 +09:00
committed by John-David Dalton
parent 3ae8f23bff
commit fe7da41956

View File

@@ -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)