Skip to content

Commit c0ed88d

Browse files
authored
Merge pull request you-dont-need#362 from ChenKun1997/patch-2
The debounce function does not work if 'immediate' is true
2 parents 8093b3e + da397f7 commit c0ed88d

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1910,11 +1910,11 @@ Create a new function that calls _func_ with _thisArg_ and _args_.
19101910
return function() {
19111911
var context = this, args = arguments;
19121912
clearTimeout(timeout);
1913+
if (immediate && !timeout) func.apply(context, args);
19131914
timeout = setTimeout(function() {
19141915
timeout = null;
19151916
if (!immediate) func.apply(context, args);
19161917
}, wait);
1917-
if (immediate && !timeout) func.apply(context, args);
19181918
};
19191919
}
19201920

0 commit comments

Comments
 (0)