CustomStringAnimator.cs 485 B

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