diff --git a/samples/RenderTest/Pages/AnimationsPage.xaml b/samples/RenderTest/Pages/AnimationsPage.xaml
index 1dc924145a..9da371f007 100644
--- a/samples/RenderTest/Pages/AnimationsPage.xaml
+++ b/samples/RenderTest/Pages/AnimationsPage.xaml
@@ -52,6 +52,8 @@
+
+
diff --git a/src/Avalonia.Animation/Animation.cs b/src/Avalonia.Animation/Animation.cs
index c91430c979..981fe127ff 100644
--- a/src/Avalonia.Animation/Animation.cs
+++ b/src/Avalonia.Animation/Animation.cs
@@ -74,9 +74,12 @@ namespace Avalonia.Animation
this.CollectionChanged += delegate { _isChildrenChanged = true; };
}
+
private void InterpretKeyframes()
{
- var handlerList = new List();
+ var handlerList = new List<(Type, AvaloniaProperty)>();
+ var kfList = new List();
+
foreach (var keyframe in this)
{
@@ -90,12 +93,45 @@ namespace Avalonia.Animation
if (!custAttr.Any())
throw new InvalidProgramException($"Type {setter.GetType()} doesn't have Animator attribute.");
- var match = (AnimatorAttribute)custAttr.First();
- if (!handlerList.Contains(match.HandlerType))
- handlerList.Add(match.HandlerType);
+ var handler = ((AnimatorAttribute)custAttr.First()).HandlerType;
+ if (!handlerList.Contains((handler, setter.Property)))
+ handlerList.Add((handler, setter.Property));
+
+ var newKF = new AnimatorKeyFrame()
+ {
+ Handler = handler,
+ Property = setter.Property,
+ Cue = keyframe.Cue,
+ KeyTime = keyframe.KeyTime,
+ timeSpanSet = keyframe.timeSpanSet,
+ cueSet = keyframe.cueSet,
+ Value = setter.Value
+ };
+
+ kfList.Add(newKF);
}
}
+ var newAnimatorInstances = new List<(Type handler, AvaloniaProperty prop, IAnimator inst)>();
+
+ foreach (var handler in handlerList)
+ {
+ var newInstance = (IAnimator)Activator.CreateInstance(handler.Item1);
+ newInstance.Property = handler.Item2;
+ newAnimatorInstances.Add((handler.Item1, handler.Item2, newInstance));
+ }
+
+ foreach (var kf in kfList)
+ {
+ var parent = newAnimatorInstances.Where(p=>p.handler == kf.Handler &&
+ p.prop == kf.Property)
+ .First();
+ parent.inst.Add(kf);
+ }
+
+ foreach(var instance in newAnimatorInstances)
+ _animators.Add(instance.inst);
+
}
///
diff --git a/src/Avalonia.Animation/AnimatorKeyFrame.cs b/src/Avalonia.Animation/AnimatorKeyFrame.cs
new file mode 100644
index 0000000000..8892dbc14b
--- /dev/null
+++ b/src/Avalonia.Animation/AnimatorKeyFrame.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.ComponentModel;
+using Avalonia.Metadata;
+using Avalonia.Collections;
+
+namespace Avalonia.Animation
+{
+
+ public class AnimatorKeyFrame
+ {
+ public Type Handler;
+ public Cue Cue;
+ public TimeSpan KeyTime;
+ internal bool timeSpanSet, cueSet;
+ internal AvaloniaProperty Property;
+ public object Value;
+ }
+
+}
diff --git a/src/Avalonia.Animation/Animator`1.cs b/src/Avalonia.Animation/Animator`1.cs
index 89da918ec3..bc848c5945 100644
--- a/src/Avalonia.Animation/Animator`1.cs
+++ b/src/Avalonia.Animation/Animator`1.cs
@@ -14,7 +14,7 @@ namespace Avalonia.Animation
///
/// Base class for KeyFrames objects
///
- public abstract class Animator : AvaloniaList, IAnimator
+ public abstract class Animator : AvaloniaList, IAnimator
{
///
/// List of type-converted keyframes.
@@ -117,7 +117,7 @@ namespace Avalonia.Animation
{
var typeConv = TypeDescriptor.GetConverter(type);
- foreach (InternalKeyFrame k in this)
+ foreach (AnimatorKeyFrame k in this)
{
if (k.Value == null)
{
diff --git a/src/Avalonia.Animation/IAnimator.cs b/src/Avalonia.Animation/IAnimator.cs
index 060236bb65..870aad9419 100644
--- a/src/Avalonia.Animation/IAnimator.cs
+++ b/src/Avalonia.Animation/IAnimator.cs
@@ -5,13 +5,19 @@ using System.Text;
namespace Avalonia.Animation
{
///
- /// Interface for Keyframe group object
+ /// Interface for Animator objects
///
- public interface IAnimator
+ public interface IAnimator : IList
{
+ ///
+ /// The target property.
+ ///
+ AvaloniaProperty Property {get; set;}
+
///
/// Applies the current KeyFrame group to the specified control.
///
IDisposable Apply(Animation animation, Animatable control, IObservable obsMatch);
+
}
}
diff --git a/src/Avalonia.Animation/KeyFrame.cs b/src/Avalonia.Animation/KeyFrame.cs
index 3ffd38e9b4..46be119c36 100644
--- a/src/Avalonia.Animation/KeyFrame.cs
+++ b/src/Avalonia.Animation/KeyFrame.cs
@@ -75,12 +75,4 @@ namespace Avalonia.Animation
}
- public class InternalKeyFrame
- {
- public Cue Cue { get; set; }
- public TimeSpan KeyTime { get; set; }
- internal bool timeSpanSet, cueSet;
- public object Value { get; set; }
- }
-
}
diff --git a/src/Avalonia.Visuals/Animation/TransformAnimator.cs b/src/Avalonia.Visuals/Animation/TransformAnimator.cs
index 7c3966ce93..46cefbd061 100644
--- a/src/Avalonia.Visuals/Animation/TransformAnimator.cs
+++ b/src/Avalonia.Visuals/Animation/TransformAnimator.cs
@@ -84,7 +84,7 @@ namespace Avalonia.Animation
{
childKeyFrames = new DoubleAnimator();
- foreach (InternalKeyFrame keyframe in this)
+ foreach (AnimatorKeyFrame keyframe in this)
{
childKeyFrames.Add(keyframe);
}