Last active
July 1, 2019 15:46
-
-
Save jyotiarora2610/eaa2c85a183b520ca577cb5ac9da29a3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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