From 5d43f8f69907191f4ec2a109f43d70dd32267479 Mon Sep 17 00:00:00 2001 From: artyom Date: Thu, 1 Oct 2020 20:23:43 +0300 Subject: [PATCH] Add a CompositeTransition --- .../Animation/CompositeTransition.cs | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/Avalonia.Visuals/Animation/CompositeTransition.cs diff --git a/src/Avalonia.Visuals/Animation/CompositeTransition.cs b/src/Avalonia.Visuals/Animation/CompositeTransition.cs new file mode 100644 index 0000000000..62ed9d5bc1 --- /dev/null +++ b/src/Avalonia.Visuals/Animation/CompositeTransition.cs @@ -0,0 +1,61 @@ +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Avalonia.Metadata; + +namespace Avalonia.Animation +{ + /// + /// Defines a composite transition that can be used to combine multiple transitions into one. + /// + /// + /// + /// Instantiate the in XAML and initialize the + /// property in order to have many animations triggered at once. + /// For example, you can combine and . + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// ]]> + /// + /// + /// + public class CompositeTransition : IPageTransition + { + /// + /// Gets or sets the transitions to be executed. Can be defined from XAML. + /// + [Content] + public List Transitions { get; set; } = new List(); + + /// + /// Starts the animation. + /// + /// + /// The control that is being transitioned away from. May be null. + /// + /// + /// The control that is being transitioned to. May be null. + /// + /// + /// Defines the direction of the transition. + /// + /// + /// A that tracks the progress of the animation. + /// + public Task Start(Visual from, Visual to, bool forward) + { + var transitionTasks = Transitions + .Select(transition => transition.Start(from, to, forward)) + .ToList(); + return Task.WhenAll(transitionTasks); + } + } +}