Skip to content

Commit

Permalink
The debounce function does not work if 'immediate' is true
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenKun1997 authored Jun 14, 2023
1 parent 8093b3e commit da397f7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1910,11 +1910,11 @@ Create a new function that calls _func_ with _thisArg_ and _args_.
return function() {
var context = this, args = arguments;
clearTimeout(timeout);
if (immediate && !timeout) func.apply(context, args);
timeout = setTimeout(function() {
timeout = null;
if (!immediate) func.apply(context, args);
}, wait);
if (immediate && !timeout) func.apply(context, args);
};
}

Expand Down

0 comments on commit da397f7

Please sign in to comment.