CustomStringAnimator.cs 538 B

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