Permalink
Browse files

test removing frames from layer. layer sets values at end of animation.

  • Loading branch information...
1 parent 4bb1fc5 commit 02988b9ad7da5f657e04705341328ea0277dfc62 @mzgoddard committed Nov 27, 2011
Showing with 66 additions and 0 deletions.
  1. +10 −0 src/abacus.animation.js
  2. +56 −0 test/unit/abacus.animation.js
View
@@ -252,6 +252,16 @@
// at end of layer?
if ( nextFrame == null ) {
+ doTween(
+ lastFrame.value,
+ lastFrame.value,
+ lastFrame.tweenable,
+ lastFrame.keys,
+ target,
+ ( lastFrame.tween || this.tween || animation.tween ).type,
+ 0
+ );
+
return false;
}
}
@@ -32,6 +32,62 @@ test('animation() fails', 1, function() {
}, 'animation() cannot be called without options object');
});
+test('layer.removeFrame', 8, function() {
+ var obj = {'x': 0, 'y': 0},
+ layer = Abacus.animation.layer({
+ tween: 'linear'
+ }),
+ fourthFrame = Abacus.animation.frame({
+ index: 40,
+ value: {'x': 8, 'y': 8}
+ });
+
+ layer.addFrame({
+ index: 0,
+ value: {'x': 0, 'y': 0}
+ });
+
+ layer.addFrame({
+ index: 10,
+ value: {'x': 1, 'y': 1}
+ });
+
+ layer.addFrame({
+ index: 20,
+ value: {'x': 4, 'y': 4}
+ });
+
+ layer.addFrame( fourthFrame );
+
+ layer.step( {rate: 5}, obj, {sinceStart: 1000} );
+
+ equal( obj.x, 0.5 );
+ equal( obj.y, 0.5 );
+
+ layer.removeFrame( 10 );
+
+ layer.step( {rate: 5}, obj, {sinceStart: 1000} );
+
+ equal( obj.x, 1 );
+ equal( obj.y, 1 );
+
+ layer.step( {rate: 5}, obj, {sinceStart: 8000} );
+
+ equal( obj.x, 8 );
+ equal( obj.y, 8 );
+
+ layer.removeFrame( fourthFrame );
+
+ layer.reset();
+ layer.step( {rate: 5}, obj, {sinceStart: 8000} );
+
+ equal( obj.x, 4 );
+ equal( obj.y, 4 );
+});
+
+test('layer sets values after hitting end of last frame', 0, function(){});
+test('layer initializes values with first frame (aka non-zero index )', 0, function(){});
+
test('layer.step updates values', 2, function() {
var position = [0, 0],
layer = Abacus.animation.layer({

0 comments on commit 02988b9

Please sign in to comment.