Skip to content

Instantly share code, notes, and snippets.

@henryoswald
Last active December 11, 2015 04:08
Show Gist options
  • Save henryoswald/4542618 to your computer and use it in GitHub Desktop.
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
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