|
@@ -19,6 +19,11 @@ Events.DragAnimationStart = "draganimationstart" |
|
|
Events.DragAnimationEnd = "draganimationend" |
|
|
Events.DirectionLockStart = "directionlockstart" |
|
|
|
|
|
# Special cases |
|
|
Events.DragSessionStart = "dragsessionstart" |
|
|
Events.DragSessionMove = "dragsessionmove" |
|
|
Events.DragSessionEnd = "dragsessionend" |
|
|
|
|
|
# Add deprecated aliases |
|
|
Events.DragAnimationDidStart = Events.DragAnimationStart |
|
|
Events.DragAnimationDidEnd = Events.DragAnimationEnd |
|
@@ -101,13 +106,16 @@ class exports.LayerDraggable extends BaseClass |
|
|
|
|
|
attach: -> |
|
|
@layer.on(Gestures.TapStart, @touchStart) |
|
|
@layer.on(Gestures.Pan, @_touchMove) |
|
|
@layer.on(Gestures.TapEnd, @_touchEnd) |
|
|
# @layer.on(Gestures.Pan, @_touchMove) |
|
|
# @layer.on(Gestures.TapEnd, @_touchEnd) |
|
|
|
|
|
|
|
|
|
|
|
@layer.on("change:x", @_updateLayerPosition) |
|
|
@layer.on("change:y", @_updateLayerPosition) |
|
|
|
|
|
remove: -> |
|
|
@layer.off(Gestures.PanStart, @touchStart) |
|
|
@layer.off(Gestures.TapStart, @touchStart) |
|
|
@layer.off(Gestures.Pan, @_touchMove) |
|
|
@layer.off(Gestures.PanEnd, @_touchEnd) |
|
|
|
|
@@ -128,6 +136,9 @@ class exports.LayerDraggable extends BaseClass |
|
|
|
|
|
_touchStart: (event) => |
|
|
|
|
|
Events.wrap(document).addEventListener(Gestures.Pan, @_touchMove) |
|
|
Events.wrap(document).addEventListener(Gestures.TapEnd, @_touchEnd) |
|
|
|
|
|
# Only reset isMoving if this was not animating when we were clicking |
|
|
# so we can use it to detect a click versus a drag. |
|
|
@_isMoving = @isAnimating |
|
@@ -176,6 +187,8 @@ class exports.LayerDraggable extends BaseClass |
|
|
@_point = @_correctedLayerStartPoint |
|
|
@_ignoreUpdateLayerPosition = false |
|
|
|
|
|
@emit(Events.DragSessionStart, event) |
|
|
|
|
|
_touchMove: (event) => |
|
|
|
|
|
return unless @enabled |
|
@@ -249,15 +262,21 @@ class exports.LayerDraggable extends BaseClass |
|
|
@emit(Events.Move, @layer.point) |
|
|
@emit(Events.DragDidMove, event) |
|
|
|
|
|
@emit(Events.DragSessionMove, event) |
|
|
|
|
|
_touchEnd: (event) => |
|
|
|
|
|
Events.wrap(document).removeEventListener(Gestures.Pan, @_touchMove) |
|
|
Events.wrap(document).removeEventListener(Gestures.TapEnd, @_touchEnd) |
|
|
|
|
|
event.stopPropagation() if @propagateEvents is false |
|
|
|
|
|
# Start the simulation prior to emitting the DragEnd event. |
|
|
# This way, if the user calls layer.animate on DragEnd, the simulation will |
|
|
# be canceled by the user's animation (if the user animates x and/or y). |
|
|
@_startSimulation() |
|
|
|
|
|
@emit(Events.DragSessionEnd, event) |
|
|
@emit(Events.DragEnd, event) if @_isDragging |
|
|
|
|
|
# Set _isDragging after DragEnd is fired, so that calls to calculateVelocity() |
|
|
This comment has been minimized.
This comment has been minimized.
So there is a new thing here:
DragSession*
vsDrag*
. The latter only gets thrown if you actually move a layer. The first one always gets thrown.