Created
June 10, 2018 12:32
-
-
Save kiok46/699f6fb447fba3a5373dd442f80f1ef3 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
// 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