Skip to content

Commit

Permalink
Merge pull request #8683 from AvaloniaUI/stop-transition-if-it-was-ca…
Browse files Browse the repository at this point in the history
…ncelled

Stop TransitioningContentControl if it was cancelled
  • Loading branch information
maxkatz6 authored and danwalmsley committed Aug 12, 2022
1 parent 7eb0a48 commit 7627db1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Avalonia.Controls/TransitioningContentControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,19 @@ private async void UpdateContentWithTransition(object? content)

_lastTransitionCts?.Cancel();
_lastTransitionCts = new CancellationTokenSource();
var localToken = _lastTransitionCts.Token;

if (PageTransition != null)
await PageTransition.Start(this, null, true, _lastTransitionCts.Token);
await PageTransition.Start(this, null, true, localToken);

if (localToken.IsCancellationRequested)
{
return;
}

CurrentContent = content;

if (PageTransition != null)
await PageTransition.Start(null, this, true, _lastTransitionCts.Token);
await PageTransition.Start(null, this, true, localToken);
}
}

0 comments on commit 7627db1

Please sign in to comment.