Skip to content

Commit af08f8c

Browse files
committed
Chore: Improve reload animation to use dynamic size
1 parent d59f5ab commit af08f8c

1 file changed

Lines changed: 17 additions & 11 deletions

File tree

Source/NETworkManager.Utilities.WPF/ReloadAnimationHelper.cs

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,26 @@ public static bool GetIsReloading(UIElement element) =>
2323

2424
private static void OnIsReloadingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
2525
{
26-
if (d is Rectangle rect && e.NewValue is bool isReloading)
26+
if (d is not Rectangle rect || e.NewValue is not bool isReloading)
27+
return;
28+
29+
if (isReloading)
2730
{
28-
if (isReloading)
31+
var rotate = new RotateTransform
2932
{
30-
var rotate = new RotateTransform { CenterX = 12, CenterY = 12 };
31-
rect.RenderTransform = rotate;
33+
CenterX = rect.Width / 2,
34+
CenterY = rect.Height / 2
35+
};
36+
37+
rect.RenderTransform = rotate;
3238

33-
var animation = new DoubleAnimation(0, 720, new Duration(TimeSpan.FromSeconds(2)));
34-
rotate.BeginAnimation(RotateTransform.AngleProperty, animation);
35-
}
36-
else
37-
{
38-
rect.RenderTransform = null;
39-
}
39+
var animation = new DoubleAnimation(0, 720, new Duration(TimeSpan.FromSeconds(2)));
40+
41+
rotate.BeginAnimation(RotateTransform.AngleProperty, animation);
42+
}
43+
else
44+
{
45+
rect.RenderTransform = null;
4046
}
4147
}
4248
}

0 commit comments

Comments
 (0)