From dfa75a6d4f5623d82bf3babe485e04a22d3425b9 Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Fri, 7 May 2021 23:21:00 +0800 Subject: [PATCH] fix bug on instances where SCB animation applies a localvalue wrongly. --- .../Animators/SolidColorBrushAnimator.cs | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Avalonia.Visuals/Animation/Animators/SolidColorBrushAnimator.cs b/src/Avalonia.Visuals/Animation/Animators/SolidColorBrushAnimator.cs index a8e618af27..42962e219e 100644 --- a/src/Avalonia.Visuals/Animation/Animators/SolidColorBrushAnimator.cs +++ b/src/Avalonia.Visuals/Animation/Animators/SolidColorBrushAnimator.cs @@ -41,23 +41,23 @@ namespace Avalonia.Animation.Animators SolidColorBrush finalTarget; var targetVal = control.GetValue(Property); - if (targetVal is null) + + switch (targetVal) { - finalTarget = new SolidColorBrush(Colors.Transparent); - control.SetValue(Property, finalTarget); - } - else if (targetVal is ImmutableSolidColorBrush immutableSolidColorBrush) - { - finalTarget = new SolidColorBrush(immutableSolidColorBrush.Color); - control.SetValue(Property, finalTarget); - } - else if (targetVal is ISolidColorBrush) - { - finalTarget = targetVal as SolidColorBrush; - } - else - { - return Disposable.Empty; + case null: + finalTarget = new SolidColorBrush(Colors.Transparent); + break; + case ImmutableSolidColorBrush immutableSolidColorBrush: + finalTarget = new SolidColorBrush(immutableSolidColorBrush.Color); + break; + case SolidColorBrush target: + finalTarget = target; + break; + case ISolidColorBrush target: + finalTarget = target as SolidColorBrush; + break; + default: + return Disposable.Empty; } if (_colorAnimator == null)