Permalink
Browse files

Merge pull request #291 from koenbok/gestures

Gestures refactor to layer.gestures
  • Loading branch information...
koenbok committed Jan 17, 2016
2 parents 27b7647 + a93c529 commit 42de49f94553e3e0319170453e51e3348d9c2b22
Showing with 821 additions and 273 deletions.
  1. +9 −0 framer/Context.coffee
  2. +2 −9 framer/DOMEventManager.coffee
  3. +0 −49 framer/Events.coffee
  4. +1 −0 framer/Framer.coffee
  5. +174 −98 framer/GestureManager.coffee
  6. +47 −0 framer/Gestures.coffee
  7. +15 −42 framer/Layer.coffee
  8. +30 −0 framer/LayerDraggable.coffee
  9. +1 −0 framer/LayerStates.coffee
  10. +9 −5 framer/Utils.coffee
  11. +7 −9 gulpfile.coffee
  12. +14 −0 test/studio/DraggableGestures.framer/app.coffee
  13. +12 −0 test/studio/DraggableGestures.framer/framer/coffee-script.js
  14. +10 −0 test/studio/DraggableGestures.framer/framer/config.json
  15. +126 −0 test/studio/DraggableGestures.framer/framer/framer.init.js
  16. +1 −0 test/studio/DraggableGestures.framer/framer/framer.js
  17. BIN test/studio/DraggableGestures.framer/framer/images/background.png
  18. BIN test/studio/DraggableGestures.framer/framer/images/cursor-active.png
  19. BIN test/studio/DraggableGestures.framer/framer/images/cursor-active@2x.png
  20. BIN test/studio/DraggableGestures.framer/framer/images/cursor.png
  21. BIN test/studio/DraggableGestures.framer/framer/images/cursor@2x.png
  22. BIN test/studio/DraggableGestures.framer/framer/images/icon-120.png
  23. BIN test/studio/DraggableGestures.framer/framer/images/icon-152.png
  24. BIN test/studio/DraggableGestures.framer/framer/images/icon-76.png
  25. BIN test/studio/DraggableGestures.framer/framer/images/icon-arrow.png
  26. BIN test/studio/DraggableGestures.framer/framer/images/icon-arrow@2x.png
  27. BIN test/studio/DraggableGestures.framer/framer/images/icon-close.png
  28. BIN test/studio/DraggableGestures.framer/framer/images/icon-close@2x.png
  29. BIN test/studio/DraggableGestures.framer/framer/images/icon-framer.png
  30. BIN test/studio/DraggableGestures.framer/framer/images/icon-framer@2x.png
  31. BIN test/studio/DraggableGestures.framer/framer/images/icon-share.png
  32. BIN test/studio/DraggableGestures.framer/framer/images/icon-share@2x.png
  33. +196 −0 test/studio/DraggableGestures.framer/framer/mirror.css
  34. +44 −0 test/studio/DraggableGestures.framer/framer/style.css
  35. +1 −0 test/studio/DraggableGestures.framer/framer/version
  36. 0 test/studio/DraggableGestures.framer/images/.gitkeep
  37. BIN test/studio/DraggableGestures.framer/images/framer-icon.png
  38. +37 −0 test/studio/DraggableGestures.framer/index.html
  39. +2 −1 test/tests.coffee
  40. +1 −60 test/tests/LayerEventsTest.coffee
  41. +74 −0 test/tests/LayerGesturesTest.coffee
  42. +8 −0 test/tests/LayerTest.coffee
@@ -89,6 +89,7 @@ class exports.Context extends BaseClass
@_layers = _.without(@_layers, layer)
resetLayers: ->
@resetGestures()
@_layers = []
@_layerCounter = 0
@@ -141,6 +142,14 @@ class exports.Context extends BaseClass
@_intervals.map(window.clearInterval) if @_intervals
@_intervals = []
# Gestures
resetGestures: ->
return unless @_layers
for layer in @_layers
if layer._gestures
layer._gestures.destroy()
return
##############################################################
# Run
@@ -9,21 +9,14 @@ EventManagerIdCounter = 0
class DOMEventManagerElement extends EventEmitter
constructor: (@element) ->
@_elementGestureManager = new GestureManagerElement(@element)
addListener: (eventName, listener, capture=false) ->
super(eventName, listener)
if Events.isGestureEvent eventName
@_elementGestureManager.addEventListener(eventName, listener, capture)
else
@element.addEventListener(eventName, listener)
@element.addEventListener(eventName, listener, false)
removeListener: (eventName, listener) ->
super(eventName, listener)
if Events.isGestureEvent eventName
@_elementGestureManager.removeEventListener(eventName, listener)
else
@element.removeEventListener(eventName, listener)
@element.removeEventListener(eventName, listener, false)
# Keep the DOM API working
addEventListener: @::addListener
@@ -35,62 +35,13 @@ Events.AnimationDidStart = "start"
Events.AnimationDidStop = "stop"
Events.AnimationDidEnd = "end"
# Gesture events
_gestures = []
# Pan
_gestures.push Events.Pan = "pan" # This event includes all the other Pan events
_gestures.push Events.PanStart = "panstart"
_gestures.push Events.PanMove = "panmove"
_gestures.push Events.PanEnd = "panend"
_gestures.push Events.PanCancel = "pancancel"
_gestures.push Events.PanLeft = "panleft"
_gestures.push Events.PanRight = "panright"
_gestures.push Events.PanUp = "panup"
_gestures.push Events.PanDown = "pandown"
# Pinch
_gestures.push Events.Pinch = "pinch" # This event includes all the other Pinch events
_gestures.push Events.PinchStart = "pinchstart"
_gestures.push Events.PinchMove = "pinchmove"
_gestures.push Events.PinchEnd = "pinchend"
_gestures.push Events.PinchCancel = "pinchcancel"
_gestures.push Events.PinchIn = "pinchin"
_gestures.push Events.PinchOut = "pinchout"
# Press
_gestures.push Events.Press = "press"
_gestures.push Events.PressUp = "pressup"
# Rotate
_gestures.push Events.Rotate = "rotate" # This event includes all the other Rotate events
_gestures.push Events.RotateStart = "rotatestart"
_gestures.push Events.RotateMove = "rotatemove"
_gestures.push Events.RotateEnd = "rotateend"
_gestures.push Events.RotateCancel = "rotatecancel"
# Swipe
_gestures.push Events.Swipe = "swipe"
_gestures.push Events.SwipeLeft = "swipeleft"
_gestures.push Events.SwipeRight = "swiperight"
_gestures.push Events.SwipeUp = "swipeup"
_gestures.push Events.SwipeDown = "swipedown"
# Tap
_gestures.push Events.Tap = "tap"
_gestures.push Events.SingleTap = "singletap"
_gestures.push Events.DoubleTap = "doubletap"
# Scroll events
Events.Scroll = "scroll"
# Image events
Events.ImageLoaded = "load"
Events.ImageLoadError = "error"
Events.isGestureEvent = (eventName) ->
return eventName in _gestures
# Extract touch events for any event
Events.touchEvent = (event) ->
touchEvent = event.touches?[0]
@@ -10,6 +10,7 @@ Framer.Layer = (require "./Layer").Layer
Framer.BackgroundLayer = (require "./BackgroundLayer").BackgroundLayer
Framer.VideoLayer = (require "./VideoLayer").VideoLayer
Framer.Events = (require "./Events").Events
Framer.Gestures = (require "./Gestures").Gestures
Framer.Animation = (require "./Animation").Animation
Framer.AnimationGroup = (require "./AnimationGroup").AnimationGroup
Framer.Screen = (require "./Screen").Screen
Oops, something went wrong.

0 comments on commit 42de49f

Please sign in to comment.