Skip to content

Instantly share code, notes, and snippets.

@kiok46
Created June 10, 2018 12:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kiok46/699f6fb447fba3a5373dd442f80f1ef3 to your computer and use it in GitHub Desktop.
Save kiok46/699f6fb447fba3a5373dd442f80f1ef3 to your computer and use it in GitHub Desktop.
// Multiple Tap Handler
const multipleTapHandler = (func, wait = 200) => {
let tapCount = 0
let handler;
return function() {
//console.log(tapCount)
if (tapCount === 0){
tapCount++;
func()
}
// Clear the previous timeout and set a new one.
clearTimeout(handler)
handler = setTimeout(() => tapCount = 0, wait)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment