Browse Source

Fix: Crossfade animation causes other animations to have hidden elements (#14832)

* Fix: Remove the property changes, let the animation take care of the opacity

* Fix: Remove disposables that are no longer required

---------

Co-authored-by: Matt Blacker <matt@aspireweb.com.au>
pull/14843/head
Matt Blacker 3 years ago
committed by GitHub
parent
commit
c5a13d8324
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 35
      src/Avalonia.Base/Animation/CrossFade.cs

35
src/Avalonia.Base/Animation/CrossFade.cs

@ -132,32 +132,23 @@ namespace Avalonia.Animation
} }
var tasks = new List<Task>(); var tasks = new List<Task>();
using (var disposables = new CompositeDisposable(1))
{
if (to != null)
{
disposables.Add(to.SetValue(Visual.OpacityProperty, 0, Data.BindingPriority.Animation)!);
}
if (from != null) if (from != null)
{ {
from.Opacity = 0f; tasks.Add(_fadeOutAnimation.RunAsync(from, null, cancellationToken));
tasks.Add(_fadeOutAnimation.RunAsync(from, null, cancellationToken)); }
}
if (to != null) if (to != null)
{ {
to.Opacity = 1f; to.IsVisible = true;
to.IsVisible = true; tasks.Add(_fadeInAnimation.RunAsync(to, null, cancellationToken));
tasks.Add(_fadeInAnimation.RunAsync(to, null, cancellationToken)); }
}
await Task.WhenAll(tasks); await Task.WhenAll(tasks);
if (from != null && !cancellationToken.IsCancellationRequested) if (from != null && !cancellationToken.IsCancellationRequested)
{ {
from.IsVisible = false; from.IsVisible = false;
}
} }
} }

Loading…
Cancel
Save