Skip to content
Permalink
Browse files

Merge pull request #458 from koenbok/feature/reset-mousemove

add reset methods to TouchEmulator and GestureInputRecognizer
  • Loading branch information
nvh committed Dec 23, 2016
2 parents 97a28ce + 3beeadb commit 386a97af1a25905964aac5e73649b64dc1cf2457
Showing with 13 additions and 2 deletions.
  1. +7 −0 framer/Extras/TouchEmulator.coffee
  2. +6 −2 framer/GestureInputRecognizer.coffee
@@ -232,3 +232,10 @@ exports.disable = ->
touchEmulator.destroy()
touchEmulator = null
Events.enableEmulatedTouchEvents(false)

# resets the emulator, useful if the webview can loose/regain focus without being aware
# in such scenarios it can miss mouseup, mouseout events and such
# it can also be fixed by checking event.buttons in mousemove, but that is not available on safari
exports.reset = ->
return unless touchEmulator
touchEmulator.endMultiTouch()
@@ -18,6 +18,7 @@ class exports.GestureInputRecognizer
@em = new DOMEventManager()
@em.wrap(window).addEventListener("mousedown", @startMouse)
@em.wrap(window).addEventListener("touchstart", @startTouch)
@session = null

destroy: ->
@em.removeAllListeners()
@@ -84,8 +85,7 @@ class exports.GestureInputRecognizer
@em.wrap(window).removeEventListener("mouseup", @touchend)
@em.wrap(window).removeEventListener("touchmove", @touchmove)
@em.wrap(window).removeEventListener("touchend", @touchend)

@em.wrap(window).addEventListener("webkitmouseforcechanged", @_updateMacForce)
@em.wrap(window).removeEventListener("webkitmouseforcechanged", @_updateMacForce)

event = @_getGestureEvent(event)

@@ -103,6 +103,10 @@ class exports.GestureInputRecognizer
@tapend(event)
@cancel()

reset: =>
return unless @session
@touchend(@session.lastEvent)

# Tap

tap: (event) => @_dispatchEvent("tap", event)

0 comments on commit 386a97a

Please sign in to comment.
You can’t perform that action at this time.