Skip to content
Permalink
Browse files

Make once work with gestures

  • Loading branch information...
Koen Bok
Koen Bok committed Jan 18, 2016
1 parent 8e8fda5 commit 325775b4f1c5dcabea99f63935c8752e9b8d7299
Showing with 15 additions and 3 deletions.
  1. +15 −3 framer/GestureManager.coffee
@@ -10,9 +10,22 @@ class exports.GestureManager extends EventEmitter
constructor: (@layer) ->
@_manager = Hammer(@layer._element)

addListener: (eventName, listener) ->

once: (eventName, listener) =>
super(eventName, listener)
@_addListener eventName, (e) =>
@removeListener(eventName, listener)
listener.apply(@layer, [e, @layer])

addListener: (eventName, listener) =>
super(eventName, listener)
@_addListener(eventName, listener)

removeListener: (eventName, listener) ->
super(eventName, listener)
@_removeListener(eventName, listener)

_addListener: (eventName, listener) ->

# Make sure we have a hammer instance and layer listeners enabled
@layer.ignoreEvents = false
@@ -37,8 +50,7 @@ class exports.GestureManager extends EventEmitter

@_manager.on(eventName, listener._actual)

removeListener: (eventName, listener) ->
super(eventName, listener)
_removeListener: (eventName, listener) ->
@_manager.off(eventName, listener._actual)

destroy: ->

0 comments on commit 325775b

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