Permalink
Browse files

Merge pull request #399 from nvh/feature/touch-emulator-events

Enable native Touch events again when disabling the TouchEmulator
  • Loading branch information...
koenbok committed Aug 15, 2016
2 parents 694b407 + c64068e commit 852cfe57f62365c02e46381e5458d02f17381dee
Showing with 16 additions and 8 deletions.
  1. +14 −8 framer/Events.coffee
  2. +2 −0 framer/Extras/TouchEmulator.coffee
View
@@ -5,11 +5,6 @@ Utils = require "./Utils"
Events = {}
# Standard touch events
Events.TouchStart = "touchstart"
Events.TouchEnd = "touchend"
Events.TouchMove = "touchmove"
# Standard dom events
Events.MouseUp = "mouseup"
Events.MouseDown = "mousedown"
@@ -20,11 +15,22 @@ Events.MouseWheel = "mousewheel"
Events.DoubleClick = "dblclick"
Events.MouseDoubleClick = "dblclick" # Alias for consistent naming
# Standard touch events
Events.enableEmulatedTouchEvents = (enable=true) ->
if enable
Events.TouchStart = Events.MouseDown
Events.TouchEnd = Events.MouseUp
Events.TouchMove = Events.MouseMove
else
Events.TouchStart = "touchstart"
Events.TouchEnd = "touchend"
Events.TouchMove = "touchmove"
Events.enableEmulatedTouchEvents(false)
# Let's make sure the touch events work on desktop too
if not Utils.isTouch()
Events.TouchStart = Events.MouseDown
Events.TouchEnd = Events.MouseUp
Events.TouchMove = Events.MouseMove
Events.enableEmulatedTouchEvents()
Events.Click = Events.TouchEnd
@@ -224,8 +224,10 @@ touchEmulator = null
exports.enable = ->
return if Utils.isTouch()
touchEmulator ?= new TouchEmulator()
Events.enableEmulatedTouchEvents(true)
exports.disable = ->
return unless touchEmulator
touchEmulator.destroy()
touchEmulator = null
Events.enableEmulatedTouchEvents(false)

0 comments on commit 852cfe5

Please sign in to comment.