Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Abort animation start if the properties are already being animated
- Loading branch information
Showing
with
29 additions
and
3 deletions.
-
+10
−3
framer/Animation.coffee
-
+19
−0
test/tests/LayerAnimationTest.coffee
|
@@ -98,11 +98,16 @@ class exports.Animation extends EventEmitter |
|
|
@_stateB[k] = v if @_stateA[k] != v |
|
|
|
|
|
if _.isEqual(@_stateA, @_stateB) |
|
|
console.warn "Nothing to animate" |
|
|
return |
|
|
console.warn "Animation: nothing to animate, all properties are equal to what it is now" |
|
|
return false |
|
|
|
|
|
# See if another animation targeting the same layer is animating the same properties |
|
|
|
|
|
for runningAnimation in @_target.animations() |
|
|
for key in _.keys(runningAnimation._stateA) |
|
|
if @_stateA.hasOwnProperty(key) |
|
|
console.warn "Animation: property #{key} is already being animated for this |
|
|
layer by another animation, so we bail" |
|
|
return false |
|
|
|
|
|
if @options.debug |
|
|
console.log "Animation.start" |
|
@@ -124,6 +129,8 @@ class exports.Animation extends EventEmitter |
|
|
else |
|
|
@_start() |
|
|
|
|
|
return true |
|
|
|
|
|
stop: (emit=true)-> |
|
|
@options.layer._context._animationList = _.without( |
|
|
@options.layer._context._animationList, @) |
|
|
|
@@ -103,6 +103,25 @@ describe "LayerAnimation", -> |
|
|
layer.x.should.be.within(10, 40) |
|
|
done() |
|
|
|
|
|
it "should not start animating the same property", -> |
|
|
|
|
|
layer = new Layer() |
|
|
|
|
|
animationA = new Animation |
|
|
layer: layer |
|
|
properties: {x:50} |
|
|
curve: "linear" |
|
|
time: 0.5 |
|
|
|
|
|
animationB = new Animation |
|
|
layer: layer |
|
|
properties: {x:50} |
|
|
curve: "linear" |
|
|
time: 0.5 |
|
|
|
|
|
animationA.start().should.equal true |
|
|
animationB.start().should.equal false |
|
|
|
|
|
describe "Context", -> |
|
|
|
|
|
it "should list running animations", -> |
|
|