CoreAnimation automatically restarts when iterationStart is set

51 Views Asked by At

I want to skip the first part of an animation and jump right to let's say 3/4 of the duration. For this purpose I build the following script in Dart.

Element target = getTarget(layer.element);
CoreAnimation animation = new CoreAnimation();
animation.target = target;
animation.duration = 2000;
animation.iterationStart = 0.75; // 1500ms
animation.keyframes = [
  {'transform': 'translate(0px, 0px)'},
  {'transform': 'translate(20px, 50px)'}
];

// I also tried to add the following attributes
animation.iterations = 1; // doesnt work 
animation.iterationCount = 1; // doesnt work

animation.play();

The animation starts at the correct position, but once it has reached its last keyframe {'transform': 'translate(20px, 50px)'} it jumps back to the first keyframe and play the complete animation again. What for gods sake is happening here? Am I missing something?

Note: I already tried to set iteration count to 1.

1

There are 1 best solutions below

5
Robert On

Try to set animation.iterations to 1.