diff --git a/src/Avalonia.Base/Animation/InterpolatingTransitionBase.cs b/src/Avalonia.Base/Animation/InterpolatingTransitionBase.cs new file mode 100644 index 0000000000..44e3129b76 --- /dev/null +++ b/src/Avalonia.Base/Animation/InterpolatingTransitionBase.cs @@ -0,0 +1,28 @@ +using System; +using Avalonia.Animation.Animators; + +namespace Avalonia.Animation; + +/// +/// The base class for user-defined transition that are doing simple value interpolation +/// +public abstract class InterpolatingTransitionBase : Transition +{ + class Animator : Animator + { + private readonly InterpolatingTransitionBase _parent; + + public Animator(InterpolatingTransitionBase parent) + { + _parent = parent; + } + + public override T Interpolate(double progress, T oldValue, T newValue) => + _parent.Interpolate(progress, oldValue, newValue); + } + + protected abstract T Interpolate(double progress, T from, T to); + + internal override IObservable DoTransition(IObservable progress, T oldValue, T newValue) => + new AnimatorTransitionObservable(new Animator(this), progress, Easing, oldValue, newValue); +} \ No newline at end of file