Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Change handling animations for the same property
If you fire multiple animations for the same property on the same layer, we now cancel the previous animation animating that property.
- Loading branch information
|
@@ -112,12 +112,14 @@ class exports.Animation extends EventEmitter |
|
|
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 |
|
|
for property, animation of @_target.animatingProperties() |
|
|
console.log(@_target.animatingProperties()) |
|
|
if @_stateA.hasOwnProperty(property) |
|
|
# We used to ignore animations that tried animation already animating properties |
|
|
# console.warn "Animation: property #{property} is already being animated for this layer by another animation, so we bail" |
|
|
|
|
|
# But after some consideration, we actually just stop the animation that is animation those properties for this one |
|
|
animation.stop() |
|
|
|
|
|
if @options.debug |
|
|
console.log "Animation.start" |
|
|
|
@@ -118,7 +118,7 @@ describe "LayerAnimation", -> |
|
|
layer.x.should.be.within(10, 40) |
|
|
done() |
|
|
|
|
|
it "should not start animating the same property", -> |
|
|
it "should cancel previous animation for the same property", -> |
|
|
|
|
|
layer = new Layer() |
|
|
|
|
@@ -134,8 +134,13 @@ describe "LayerAnimation", -> |
|
|
curve: "linear" |
|
|
time: 0.5 |
|
|
|
|
|
stopped = false |
|
|
animationA.on "stop", -> stopped = true |
|
|
|
|
|
animationA.start().should.equal true |
|
|
animationB.start().should.equal false |
|
|
animationB.start().should.equal true |
|
|
|
|
|
stopped.should.equal true |
|
|
|
|
|
describe "Context", -> |
|
|
|
|
|
|
@@ -356,8 +356,6 @@ describe "Layer", -> |
|
|
|
|
|
layer.on "click", "tap", handler |
|
|
|
|
|
console.log layer._eventListeners |
|
|
|
|
|
layer.emit "click" |
|
|
layer.emit "tap" |
|
|
|
|
|