Skip to content

Instantly share code, notes, and snippets.

@jyotiarora2610
Last active July 1, 2019 15:46
Show Gist options
  • Save jyotiarora2610/eaa2c85a183b520ca577cb5ac9da29a3 to your computer and use it in GitHub Desktop.
Save jyotiarora2610/eaa2c85a183b520ca577cb5ac9da29a3 to your computer and use it in GitHub Desktop.
window.addEventListener('mousemove', debounce(eventHandler, 2000));
function debounce (cb, wait) {
var timeoutID
return function (...args) {
clearTimeout(timeoutID)
timeoutID = setTimeout(() => cb.apply(this, args), wait)
}
}
function eventHandler() {
console.log('mouse moved')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment