2using System.Runtime.ExceptionServices;
4using System.Threading.Tasks;
5using Microsoft.Maui.ApplicationModel;
6using Microsoft.Maui.Controls;
15 private readonly
double? fromX;
16 private readonly
double? fromY;
17 private readonly
double toX;
18 private readonly
double toY;
41 ArgumentNullException.ThrowIfNull(Target);
42 ArgumentNullException.ThrowIfNull(Context);
46 Target.TranslationX = this.toX;
47 Target.TranslationY = this.toY;
51 if (this.fromX.HasValue)
52 Target.TranslationX = this.fromX.Value;
53 if (this.fromY.HasValue)
54 Target.TranslationY = this.fromY.Value;
57 Func<CancellationToken, Task> Execute =
_ => Target.TranslateToAsync(this.toX, this.toY, DurationMs, this.
Easing);
58 ExceptionDispatchInfo? DispatchInfo =
null;
65 DispatchInfo = ExceptionDispatchInfo.Capture(Ex);
69 await this.ApplyFinalTranslationAsync(Target);
72 DispatchInfo?.Throw();
75 private Task ApplyFinalTranslationAsync(VisualElement Target)
77 return MainThread.InvokeOnMainThreadAsync(() =>
79 Target.TranslationX = this.toX;
80 Target.TranslationY = this.toY;
Options applied for an individual animation execution.
bool ForceMotion
Gets or sets a value indicating whether motion should run even when global settings request reduced m...
Helper class providing consistent animation execution semantics.
static async Task RunAsync(VisualElement Target, Func< CancellationToken, Task > Execute, CancellationToken Token)
Executes an animation while wiring cancellation tokens to MAUI animation APIs.
Base class providing timing helpers for view animations.
uint ResolveDurationMilliseconds(IAnimationContext Context, AnimationOptions? Options)
Resolves the duration expressed in milliseconds.
Easing Easing
Gets the base easing.
Represents a translation animation affecting the X and Y axes.
TranslateAnimation(TimeSpan Duration, Easing Easing, double? FromX, double? FromY, double ToX, double ToY)
Initializes a new instance of the TranslateAnimation class.
override async Task RunAsync(VisualElement Target, IAnimationContext Context, AnimationOptions? Options, CancellationToken Token)
Executes the animation against the specified target. Task tracking execution.
Represents contextual information required when executing an animation.
bool ReduceMotion
Gets a value indicating whether the caller requests reduced motion.