Skip to content

Instantly share code, notes, and snippets.

@Soontao
Created January 5, 2021 05:57
Show Gist options
  • Save Soontao/2f1e8de4b464d342ebf66b5c076fd728 to your computer and use it in GitHub Desktop.
Save Soontao/2f1e8de4b464d342ebf66b5c076fd728 to your computer and use it in GitHub Desktop.
debounce function
function debounce(func, wait) {
var timer;
return function () {
var context = this, args = arguments;
clearTimeout(timer);
timer = setTimeout(function () {
timer = null;
func.apply(context, args);
}, wait);
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment