FloatTransition.cs 591 B

12345678910111213141516171819
  1. using System;
  2. using System.Reactive.Linq;
  3. namespace Avalonia.Animation
  4. {
  5. /// <summary>
  6. /// Transition class that handles <see cref="AvaloniaProperty"/> with <see cref="float"/> types.
  7. /// </summary>
  8. public class FloatTransition : Transition<float>
  9. {
  10. /// <inheritdocs/>
  11. public override IObservable<float> DoTransition(IObservable<double> progress, float oldValue, float newValue)
  12. {
  13. var delta = newValue - oldValue;
  14. return progress
  15. .Select(p => (float)Easing.Ease(p) * delta + oldValue);
  16. }
  17. }
  18. }