Permalink
Browse files

Cleanup for stopping animations on draggable

  • Loading branch information...
Koen Bok
Koen Bok committed Feb 17, 2016
1 parent b7039f5 commit 9f41c24f76ccfd002d728a8bbd8f907320b56486
Showing with 22 additions and 6 deletions.
  1. +3 −1 framer/LayerDraggable.coffee
  2. +19 −5 test/tests/LayerTest.coffee
@@ -132,8 +132,10 @@ class exports.LayerDraggable extends BaseClass
# so we can use it to detect a click versus a drag.
@_isMoving = @isAnimating
# Stop any animations influencing the position, but no others.
for animation in @layer.animations()
if animation.options.properties.hasOwnProperty('x') or animation.options.properties.hasOwnProperty('y')
properties = animation.options.properties
if properties.hasOwnProperty("x") or properties.hasOwnProperty("y")
animation.stop()
@_stopSimulation()
@@ -1026,10 +1026,24 @@ describe "Layer", ->
copy.width.should.equal 100
copy.height.should.equal 100
# it "copied layer should copy styles", ->
# layer = new Layer
# layer.style.backgroundColor = "yellow"
describe "Draggable", ->
it "should stop x and y animations on drag start", ->
layer = new Layer
layer.draggable.enabled = true
a1 = layer.animate properties: {x:100}
a2 = layer.animate properties: {y:100}
a3 = layer.animate properties: {blur:1}
a1.isAnimating.should.equal true
a2.isAnimating.should.equal true
a3.isAnimating.should.equal true
layer.draggable.touchStart(document.createEvent("MouseEvent"))
# layer2 = layer.copy()
# layer2.style.backgroundColor.should.equal "yellow"
a1.isAnimating.should.equal false
a2.isAnimating.should.equal false
a3.isAnimating.should.equal true

2 comments on commit 9f41c24

@koenbok

This comment has been minimized.

Owner

koenbok replied Feb 17, 2016

@fverloop check out:

  • Nice comments
  • Small cleanup (got rid of the long line)
  • Added a test (so we know it keeps working)
@fverloop

This comment has been minimized.

Collaborator

fverloop replied Feb 18, 2016

Much better, tests seem pretty powerful too 👍

Please sign in to comment.