diff --git a/src/utils/debounce.ts b/src/utils/debounce.ts index 106ad0f9..769091e7 100644 --- a/src/utils/debounce.ts +++ b/src/utils/debounce.ts @@ -30,7 +30,7 @@ export function debounce(fn: T, options: DebounceOptions = {} const debounced = function (this: ThisParameterType, ...args: Parameters) { const invokeLeading = leading && !leadingInvoked - const later = () => { + const invoke = () => { timeoutId = null if (trailing && !leadingInvoked) fn.apply(this, args) leadingInvoked = false @@ -43,12 +43,12 @@ export function debounce(fn: T, options: DebounceOptions = {} fn.apply(this, args) } - timeoutId = setTimeout(() => later(), wait) + timeoutId = setTimeout(invoke, wait) - if (!leading && !trailing && !timeoutId) { - fn.apply(this, args) - leadingInvoked = false - } + // if (!leading && !trailing) { + // fn.apply(this, args) + // leadingInvoked = false + // } } debounced.clear = () => {