Skip to content
Browse files

Merge pull request #440 from koenbok/fix-ismoving

LayerDraggable reset @_isMoving

After some private discussion @onnlucky has me convinced that using the `_` variables is not a problem here.
  • Loading branch information
nvh committed Nov 7, 2016
2 parents 95260da + b7b4178 commit 82847238beae9c70dd8012199a252c3bdac916f2
Showing with 22 additions and 3 deletions.
  1. +1 −0 framer/Components/
  2. +7 −2 framer/
  3. +14 −1 test/tests/
@@ -61,6 +61,7 @@ class exports.ScrollComponent extends Layer
@define "speedY", @proxyProperty("content.draggable.speedY")
@define "isDragging", @proxyProperty("content.draggable.isDragging", {importable: false, exportable: false})
@define "isMoving", @proxyProperty("content.draggable.isMoving", {importable: false, exportable: false})
@define "isAnimating", @proxyProperty("content.draggable.isAnimating", {importable: false, exportable: false})
@define "propagateEvents", @proxyProperty("content.draggable.propagateEvents")
@define "directionLock", @proxyProperty("content.draggable.directionLock")
@define "directionLockThreshold", @proxyProperty("content.draggable.directionLockThreshold")
@@ -140,7 +140,7 @@ class exports.LayerDraggable extends BaseClass

# 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
@_isMoving = @_isAnimating

# Stop any animations influencing the position, but no others.
for animation in @layer.animations()
@@ -278,6 +278,9 @@ class exports.LayerDraggable extends BaseClass
# (which would return a stale value before the simulation had finished one tick)
# and because @_start currently calls calculateVelocity().
@_isDragging = false

# reset isMoving if not animating, otherwise animation start/stop will reset it
@_isMoving = @_isAnimating
@_ignoreUpdateLayerPosition = true
@_lastEvent = null
@@ -569,12 +572,14 @@ class exports.LayerDraggable extends BaseClass

_stopSimulation: =>
@emit(Events.Move, @layer.point) if @_isMoving
@_isAnimating = false
@_isMoving = false

return unless @_simulation
@_simulation = null
@emit(Events.Move, @layer.point)

animateStop: ->
@@ -1,3 +1,4 @@
assert = require "assert"

describe "ScrollComponent", ->

@@ -93,12 +94,24 @@ describe "ScrollComponent", ->
height: 400
parent: scroll.content

# also check isMoving, isDragging, isAnimating throughout this test
# TODO should be separate, when we can actually trick time
assert !scroll.isMoving, "must not be moving at start"

# collect the move events as they happen
moves = []
scroll.on Events.Move, (event) -> moves.push scroll.direction
scroll.on Events.Move, (event) ->
#console.log "MOVE", scroll.isMoving, scroll.direction
assert scroll.isMoving, "move must be moving"
assert scroll.isDragging or scroll.isAnimating, "move must have reason"
moves.push scroll.direction

# verify the timeline of move events looks good
draggable.on Events.DragAnimationEnd, (event) ->
#console.log "END", scroll.isMoving, scroll.direction
assert !scroll.isMoving, "no more moving"
assert !scroll.isAnimating, "no more animating"
assert !scroll.isDragging, "no more dragging"
ups = _.lastIndexOf(moves, "up")
downs = moves.indexOf("down")
nulls = moves.indexOf(null)

0 comments on commit 8284723

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