Browse Source

Apply easing.

Dariusz Komosinski 4 years ago
parent
commit
54090bc1f7

+ 1 - 1
src/Avalonia.Animation/AnimatorDrivenTransition.cs

@@ -9,7 +9,7 @@ namespace Avalonia.Animation
 
         public override IObservable<T> DoTransition(IObservable<double> progress, T oldValue, T newValue)
         {
-            return new AnimatorTransitionObservable<T, TAnimator>(s_animator, progress, oldValue, newValue);
+            return new AnimatorTransitionObservable<T, TAnimator>(s_animator, progress, Easing, oldValue, newValue);
         }
     }
 }

+ 7 - 2
src/Avalonia.Animation/AnimatorTransitionObservable.cs

@@ -1,24 +1,29 @@
 using System;
 using Avalonia.Animation.Animators;
+using Avalonia.Animation.Easings;
 
 namespace Avalonia.Animation
 {
     public class AnimatorTransitionObservable<T, TAnimator> : TransitionObservableBase<T> where TAnimator : Animator<T>
     {
         private readonly TAnimator _animator;
+        private readonly Easing _easing;
         private readonly T _oldValue;
         private readonly T _newValue;
 
-        public AnimatorTransitionObservable(TAnimator animator, IObservable<double> progress, T oldValue, T newValue) : base(progress)
+        public AnimatorTransitionObservable(TAnimator animator, IObservable<double> progress, Easing easing, T oldValue, T newValue) : base(progress)
         {
             _animator = animator;
+            _easing = easing;
             _oldValue = oldValue;
             _newValue = newValue;
         }
 
         protected override T ProduceValue(double progress)
         {
+            progress = _easing.Ease(progress);
+
             return _animator.Interpolate(progress, _oldValue, _newValue);
         }
     }
-}
+}

+ 1 - 1
src/Avalonia.Visuals/Animation/Transitions/TransformOperationsTransition.cs

@@ -20,7 +20,7 @@ namespace Avalonia.Animation
             var newTransform = TransformOperationsAnimator.EnsureOperations(newValue);
 
             return new AnimatorTransitionObservable<TransformOperations, TransformOperationsAnimator>(
-                s_operationsAnimator, progress, oldTransform, newTransform);
+                s_operationsAnimator, progress, Easing, oldTransform, newTransform);
         }
     }
 }