Skip to content

Commit ca2d696

Browse files
committed
Remove redundant animation and potential position change
1 parent 6744e21 commit ca2d696

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public partial class MainWindow
2929
private NotifyIcon _notifyIcon;
3030
private ContextMenu contextMenu;
3131
private MainViewModel _viewModel;
32+
private bool _animating;
3233

3334
#endregion
3435

@@ -37,8 +38,8 @@ public MainWindow(Settings settings, MainViewModel mainVM)
3738
DataContext = mainVM;
3839
_viewModel = mainVM;
3940
_settings = settings;
40-
InitializePosition();
4141
InitializeComponent();
42+
InitializePosition();
4243
}
4344

4445
public MainWindow()
@@ -180,7 +181,7 @@ private void InitializeNotifyIcon()
180181

181182
var header = new MenuItem
182183
{
183-
Header = "Flow Launcher",
184+
Header = "Flow Launcher",
184185
IsEnabled = false
185186
};
186187
var open = new MenuItem
@@ -237,6 +238,10 @@ private void InitProgressbarAnimation()
237238

238239
public void WindowAnimator()
239240
{
241+
if (_animating)
242+
return;
243+
244+
_animating = true;
240245
UpdatePosition();
241246
Storyboard sb = new Storyboard();
242247
var da = new DoubleAnimation
@@ -269,6 +274,7 @@ public void WindowAnimator()
269274
sb.Children.Add(da);
270275
sb.Children.Add(da2);
271276
sb.Children.Add(da3);
277+
sb.Completed += (_, _) => _animating = false;
272278
sb.Begin(FlowMainWindow);
273279
}
274280

@@ -322,6 +328,9 @@ private void OnDeactivated(object sender, EventArgs e)
322328

323329
private void UpdatePosition()
324330
{
331+
if (_animating)
332+
return;
333+
325334
if (_settings.RememberLastLaunchLocation)
326335
{
327336
Left = _settings.WindowLeft;
@@ -337,6 +346,8 @@ private void UpdatePosition()
337346

338347
private void OnLocationChanged(object sender, EventArgs e)
339348
{
349+
if (_animating)
350+
return;
340351
if (_settings.RememberLastLaunchLocation)
341352
{
342353
_settings.WindowLeft = Left;

0 commit comments

Comments
 (0)