浏览代码

Minor fix.

Jumar Macato 7 年之前
父节点
当前提交
d78840d756
共有 1 个文件被更改,包括 16 次插入17 次删除
  1. 16 17
      src/Avalonia.Visuals/Animation/Keyframes/TransformKeyFrames.cs

+ 16 - 17
src/Avalonia.Visuals/Animation/Keyframes/TransformKeyFrames.cs

@@ -22,37 +22,36 @@ namespace Avalonia.Animation.Keyframes
         {
         {
             var ctrl = (Visual)control;
             var ctrl = (Visual)control;
 
 
-            // Check if the AvaloniaProperty is Transform derived.
-            if (typeof(Transform).IsAssignableFrom(Property.OwnerType))
+            // Check if the Target Property is Transform derived.
+            if (typeof(Transform).IsAssignableFrom(Property.OwnerType) && ctrl.RenderTransform != null)
             {
             {
                 var renderTransformType = ctrl.RenderTransform.GetType();
                 var renderTransformType = ctrl.RenderTransform.GetType();
-
+                
                 if (childKeyFrames == null)
                 if (childKeyFrames == null)
                 {
                 {
                     InitializeInternalDoubleKeyFrames();
                     InitializeInternalDoubleKeyFrames();
                 }
                 }
 
 
-                if(ctrl.RenderTransform != null)
+                // It's only 1 transform object so let's target that.
+                if (renderTransformType == Property.OwnerType)
                 {
                 {
-                    // It's only 1 transform object so let's target that.
-                    if (renderTransformType == Property.OwnerType)
-                    {
-                        return childKeyFrames.Apply(animation, ctrl.RenderTransform, obsMatch);
-                    }
-                    else if (renderTransformType == typeof(TransformGroup))
+                    return childKeyFrames.Apply(animation, ctrl.RenderTransform, obsMatch);
+                }
+                // Try if the control's RenderTransform is a TransformGroup and find 
+                // the target there.
+                else if (renderTransformType == typeof(TransformGroup))
+                {
+                    foreach (Transform transform in ((TransformGroup)ctrl.RenderTransform).Children)
                     {
                     {
-                        foreach (Transform transform in ((TransformGroup)ctrl.RenderTransform).Children)
+                        if (transform.GetType() == Property.OwnerType)
                         {
                         {
-                            if (transform.GetType() == Property.OwnerType)
-                            {
-                                return childKeyFrames.Apply(animation, transform, obsMatch);
-                            }
+                            return childKeyFrames.Apply(animation, transform, obsMatch);
                         }
                         }
                     }
                     }
-
-                    //throw new InvalidOperationException($"TransformKeyFrame hasn't found an appropriate Transform object with type {Property.OwnerType} in target {control}.");
                 }
                 }
 
 
+                //throw new InvalidOperationException($"TransformKeyFrame hasn't found an appropriate Transform object with type {Property.OwnerType} in target {control}.");
+
                 return null;
                 return null;
 
 
             }
             }