CustomStringAnimator.cs 521 B

1234567891011121314151617
  1. using Avalonia.Animation;
  2. using Avalonia.Animation.Animators;
  3. namespace RenderDemo.Pages
  4. {
  5. public class CustomStringAnimator : CustomAnimatorBase<string>
  6. {
  7. public override string Interpolate(double progress, string oldValue, string newValue)
  8. {
  9. if (newValue.Length == 0) return "";
  10. var step = 1.0 / newValue.Length;
  11. var length = (int)(progress / step);
  12. var result = newValue.Substring(0, length + 1);
  13. return result;
  14. }
  15. }
  16. }