Ver código fonte

Fixed delay logic on keyframe statemachine.

Jumar Macato 7 anos atrás
pai
commit
c854521992

+ 1 - 1
samples/RenderTest/Pages/AnimationsPage.xaml

@@ -18,7 +18,7 @@
       <Style Selector="Border.Rect1:pointerover">
         <Setter Property="Opacity" Value="0.5"/>
         <Style.Animations>
-          <Animation Duration="0:0:2.5" Easing="SineEaseInOut">
+          <Animation Duration="0:0:2.5" Easing="SineEaseInOut" Delay="0:0:5">
             <TransformKeyFrames Property="RotateTransform.Angle">
               <KeyFrame Cue="0%" Value="0"/>
               <KeyFrame Cue="100%" Value="360"/>

+ 6 - 2
src/Avalonia.Animation/Keyframes/KeyFramesStateMachine.cs

@@ -82,7 +82,10 @@ namespace Avalonia.Animation.Keyframes
                     break;
             }
 
-            _currentState = KeyFramesStates.DO_RUN;
+            if (_durationTotalFrameCount > 0)
+                _currentState = KeyFramesStates.DO_DELAY;
+            else
+                _currentState = KeyFramesStates.DO_RUN;
         }
 
         public double Step(PlayState _playState, Func<double, T> Interpolator)
@@ -106,9 +109,10 @@ namespace Avalonia.Animation.Keyframes
             switch (_currentState)
             {
                 case KeyFramesStates.DO_DELAY:
-                    if (_delayFrameCount >= _delayTotalFrameCount)
+                    if (_delayFrameCount > _delayTotalFrameCount)
                     {
                         _currentState = KeyFramesStates.DO_RUN;
+                        goto checkstate;
                     }
                     _delayFrameCount++;
                     return 0d;