Created
September 28, 2020 13:42
-
-
Save tcelestino/522296674d193737f05d71c572af0535 to your computer and use it in GitHub Desktop.
simple debounce
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
let timeout; | |
const debounce = (func, wait) => { | |
clearTimeout(timeout); | |
timeout = setTimeout(func, wait); | |
}; | |
const handleInput = () => { | |
debounce(() => { | |
format(); | |
setCaret(); | |
}, 200); | |
}; | |
container.addEventListener("input", handleInput); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment