From c5a13d832468b1c0150fe39ff17200a4ce830c6a Mon Sep 17 00:00:00 2001 From: Matt Blacker Date: Wed, 6 Mar 2024 15:45:03 +1100 Subject: [PATCH] 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 --- src/Avalonia.Base/Animation/CrossFade.cs | 35 +++++++++--------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/src/Avalonia.Base/Animation/CrossFade.cs b/src/Avalonia.Base/Animation/CrossFade.cs index d598db870f..99b34e1ff0 100644 --- a/src/Avalonia.Base/Animation/CrossFade.cs +++ b/src/Avalonia.Base/Animation/CrossFade.cs @@ -132,32 +132,23 @@ namespace Avalonia.Animation } var tasks = new List(); - using (var disposables = new CompositeDisposable(1)) - { - if (to != null) - { - disposables.Add(to.SetValue(Visual.OpacityProperty, 0, Data.BindingPriority.Animation)!); - } - if (from != null) - { - from.Opacity = 0f; - tasks.Add(_fadeOutAnimation.RunAsync(from, null, cancellationToken)); - } + if (from != null) + { + tasks.Add(_fadeOutAnimation.RunAsync(from, null, cancellationToken)); + } - if (to != null) - { - to.Opacity = 1f; - to.IsVisible = true; - tasks.Add(_fadeInAnimation.RunAsync(to, null, cancellationToken)); - } + if (to != null) + { + to.IsVisible = true; + tasks.Add(_fadeInAnimation.RunAsync(to, null, cancellationToken)); + } - await Task.WhenAll(tasks); + await Task.WhenAll(tasks); - if (from != null && !cancellationToken.IsCancellationRequested) - { - from.IsVisible = false; - } + if (from != null && !cancellationToken.IsCancellationRequested) + { + from.IsVisible = false; } }