Returns a Stream of translated values which fires for time
seconds.
The stream returns the translated values based on the transition
and
the time elapsed since the start of the method. The stream ends
automatically after time
seconds.
This method is based on the onElapsedTimeChange stream and is therefore executed before all other animatables.
var transition = Transition.easeInSine;
await for (var value in juggler.translation(0.0, 10.0, 5.0, transition)) {
print(value);
}
Source
Stream<num> translation(num startValue, num targetValue, num time, [TransitionFunction transition = Transition.linear]) async* { var startTime = this.elapsedTime; var deltaValue = targetValue - startValue; await for (var elapsedTime in this.onElapsedTimeChange) { var currentTime = elapsedTime - startTime; var clampedTime = currentTime < time ? currentTime : time; yield startValue + deltaValue * transition(clampedTime / time); if (currentTime >= time) break; } }