Skip to content

Instantly share code, notes, and snippets.

@yoavmatchulsky
Created March 25, 2017 12:03
Show Gist options
  • Save yoavmatchulsky/b7e1c9bb6f79b72d4de72e52a4ca1f11 to your computer and use it in GitHub Desktop.
Save yoavmatchulsky/b7e1c9bb6f79b72d4de72e52a4ca1f11 to your computer and use it in GitHub Desktop.
is_event_supported : (event) ->
eventName = "on#{event}"
element = document.createElement('div')
supported_in_ff = ->
element.setAttribute eventName, 'return;'
typeof element[eventName] is 'function'
supported = eventName in element || supported_in_ff()
element = null
supported
touch_event = if is_event_supported('touchstart') then 'touchstart' else 'click'
$elem.on(touch_event, (e) -> )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment