Last active
December 11, 2015 04:08
-
-
Save henryoswald/4542618 to your computer and use it in GitHub Desktop.
simple way to prevent double clicks in a client side app but still register single clicks
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
cachedEvents: {} | |
onlySingleClick: (e, waitBetweenClicks = 500)-> | |
foundTime = cachedEvents[e.target] | |
now = new Date().getTime() | |
difference = now - foundTime | |
cachedEvents[e.target] = now | |
return difference > waitBetweenClicks |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment