diff --git a/UICompositionAnimations/Behaviours/AttachedCompositionEffectFactory.cs b/UICompositionAnimations/Behaviours/AttachedCompositionEffectFactory.cs
index c25b384..b6a5f7a 100644
--- a/UICompositionAnimations/Behaviours/AttachedCompositionEffectFactory.cs
+++ b/UICompositionAnimations/Behaviours/AttachedCompositionEffectFactory.cs
@@ -166,8 +166,8 @@ const String
if (fadeIn)
{
// Fade the effect in
- ScalarKeyFrameAnimation opacityAnimation = sprite.Compositor.CreateScalarKeyFrameAnimation(1, 0,
- TimeSpan.FromMilliseconds(ms), null, sprite.GetEasingFunction(EasingFunctionNames.Linear));
+ ScalarKeyFrameAnimation opacityAnimation = sprite.Compositor.CreateScalarKeyFrameAnimation(0,
+ 1, TimeSpan.FromMilliseconds(ms), null, sprite.GetEasingFunction(EasingFunctionNames.Linear));
sprite.StartAnimation("Opacity", opacityAnimation);
}
diff --git a/UICompositionAnimations/Composition/CompositionManager.cs b/UICompositionAnimations/Composition/CompositionManager.cs
index c42b01d..6317dde 100644
--- a/UICompositionAnimations/Composition/CompositionManager.cs
+++ b/UICompositionAnimations/Composition/CompositionManager.cs
@@ -2,52 +2,135 @@
using System.Numerics;
using Windows.UI.Composition;
using Windows.UI.Xaml;
+using JetBrains.Annotations;
namespace UICompositionAnimations.Composition
{
///
/// Create composition animations using this class
///
- internal static class CompositionManager
+ public static class CompositionManager
{
- // UIElement scalar animation
- public static void BeginScalarAnimation(UIElement element, String propertyPath, float to, float? from, TimeSpan duration, TimeSpan? delay, CompositionEasingFunction ease)
+ #region Animations initialization
+
+ ///
+ /// Creates and starts a scalar animation on the target element
+ ///
+ /// The element to animate
+ /// The path that identifies the property to animate
+ /// The optional starting value for the animation
+ /// The final value for the animation
+ /// The animation duration
+ /// The optional initial delay for the animation
+ /// The optional easing function for the animation
+ [PublicAPI]
+ public static void BeginScalarAnimation([NotNull] UIElement element, [NotNull] String propertyPath,
+ float? from, float to, TimeSpan duration, TimeSpan? delay, [CanBeNull] CompositionEasingFunction ease = null)
{
- element.GetVisual().BeginScalarAnimation(propertyPath, to, from, duration, delay, ease);
+ element.GetVisual().BeginScalarAnimation(propertyPath, from, to, duration, delay, ease);
}
- // UIElement Vector2 animation
- public static void BeginVector2Animation(UIElement element, String propertyPath, Vector2 to, Vector2? from, TimeSpan duration, TimeSpan? delay, CompositionEasingFunction ease)
+ ///
+ /// Creates and starts a animation on the target element
+ ///
+ /// The element to animate
+ /// The path that identifies the property to animate
+ /// The optional starting value for the animation
+ /// The final value for the animation
+ /// The animation duration
+ /// The optional initial delay for the animation
+ /// The optional easing function for the animation
+ [PublicAPI]
+ public static void BeginVector2Animation([NotNull] UIElement element, [NotNull] String propertyPath,
+ Vector2? from, Vector2 to, TimeSpan duration, TimeSpan? delay, [CanBeNull] CompositionEasingFunction ease = null)
{
- element.GetVisual().BeginVector2Animation(propertyPath, to, from, duration, delay, ease);
+ element.GetVisual().BeginVector2Animation(propertyPath, from, to, duration, delay, ease);
}
- // UIElement Vector3 animation
- public static void BeginVector3Animation(UIElement element, String propertyPath, Vector3 to, Vector3? from, TimeSpan duration, TimeSpan? delay, CompositionEasingFunction ease)
+ ///
+ /// Creates and starts a animation on the target element
+ ///
+ /// The element to animate
+ /// The path that identifies the property to animate
+ /// The optional starting value for the animation
+ /// The final value for the animation
+ /// The animation duration
+ /// The optional initial delay for the animation
+ /// The optional easing function for the animation
+ public static void BeginVector3Animation([NotNull] UIElement element, [NotNull] String propertyPath,
+ Vector3? from, Vector3 to, TimeSpan duration, TimeSpan? delay, [CanBeNull] CompositionEasingFunction ease = null)
{
- element.GetVisual().BeginVector3Animation(propertyPath, to, from, duration, delay, ease);
+ element.GetVisual().BeginVector3Animation(propertyPath, from, to, duration, delay, ease);
}
- // CompositionObject scalar animation
- public static void BeginScalarAnimation(this CompositionObject compObj, String propertyPath, float to, float? from, TimeSpan duration, TimeSpan? delay, CompositionEasingFunction ease)
+ ///
+ /// Creates and starts a scalar animation on the current
+ ///
+ /// The target to animate
+ /// The path that identifies the property to animate
+ /// The optional starting value for the animation
+ /// The final value for the animation
+ /// The animation duration
+ /// The optional initial delay for the animation
+ /// The optional easing function for the animation
+ [PublicAPI]
+ public static void BeginScalarAnimation([NotNull] this CompositionObject compObj, [NotNull] String propertyPath,
+ float? from, float to, TimeSpan duration, TimeSpan? delay, [CanBeNull] CompositionEasingFunction ease = null)
{
- compObj.StartAnimation(propertyPath, compObj.Compositor.CreateScalarKeyFrameAnimation(to, from, duration, delay, ease));
+ compObj.StartAnimation(propertyPath, compObj.Compositor.CreateScalarKeyFrameAnimation(from, to, duration, delay, ease));
}
- // CompositionObject Vector2 animation
- public static void BeginVector2Animation(this CompositionObject compObj, String propertyPath, Vector2 to, Vector2? from, TimeSpan duration, TimeSpan? delay, CompositionEasingFunction ease)
+ ///
+ /// Creates and starts a animation on the current
+ ///
+ /// The target to animate
+ /// The path that identifies the property to animate
+ /// The optional starting value for the animation
+ /// The final value for the animation
+ /// The animation duration
+ /// The optional initial delay for the animation
+ /// The optional easing function for the animation
+ [PublicAPI]
+ public static void BeginVector2Animation([NotNull]this CompositionObject compObj, [NotNull] String propertyPath,
+ Vector2? from, Vector2 to, TimeSpan duration, TimeSpan? delay, [CanBeNull] CompositionEasingFunction ease = null)
{
- compObj.StartAnimation(propertyPath, compObj.Compositor.CreateVector2KeyFrameAnimation(to, from, duration, delay, ease));
+ compObj.StartAnimation(propertyPath, compObj.Compositor.CreateVector2KeyFrameAnimation(from, to, duration, delay, ease));
}
- // CompositionObject Vector3 animation
- public static void BeginVector3Animation(this CompositionObject compObj, String propertyPath, Vector3 to, Vector3? from, TimeSpan duration, TimeSpan? delay, CompositionEasingFunction ease)
+ ///
+ /// Creates and starts a animation on the current
+ ///
+ /// The target to animate
+ /// The path that identifies the property to animate
+ /// The optional starting value for the animation
+ /// The final value for the animation
+ /// The animation duration
+ /// The optional initial delay for the animation
+ /// The optional easing function for the animation
+ [PublicAPI]
+ public static void BeginVector3Animation([NotNull] this CompositionObject compObj, [NotNull] String propertyPath,
+ Vector3? from, Vector3 to, TimeSpan duration, TimeSpan? delay, [CanBeNull] CompositionEasingFunction ease = null)
{
- compObj.StartAnimation(propertyPath, compObj.Compositor.CreateVector3KeyFrameAnimation(to, from, duration, delay, ease));
+ compObj.StartAnimation(propertyPath, compObj.Compositor.CreateVector3KeyFrameAnimation(from, to, duration, delay, ease));
}
- // Create scalar animation from compositor
- public static ScalarKeyFrameAnimation CreateScalarKeyFrameAnimation(this Compositor compositor, float to, float? from, TimeSpan duration, TimeSpan? delay, CompositionEasingFunction ease)
+ #endregion
+
+ #region KeyFrame animations
+
+ ///
+ /// Creates a instance with the given parameters to on a target element
+ ///
+ /// The current instance used to create the animation
+ /// The optional starting value for the animation
+ /// The final value for the animation
+ /// The animation duration
+ /// The optional initial delay for the animation
+ /// The optional easing function for the animation
+ [PublicAPI]
+ [Pure, NotNull]
+ public static ScalarKeyFrameAnimation CreateScalarKeyFrameAnimation([NotNull] this Compositor compositor,
+ float? from, float to, TimeSpan duration, TimeSpan? delay, [CanBeNull] CompositionEasingFunction ease = null)
{
// Set duration and delay time
ScalarKeyFrameAnimation ani = compositor.CreateScalarKeyFrameAnimation();
@@ -60,8 +143,19 @@ public static ScalarKeyFrameAnimation CreateScalarKeyFrameAnimation(this Composi
return ani;
}
- // Create expression scalar animation from compositor
- public static ScalarKeyFrameAnimation CreateScalarKeyFrameAnimation(this Compositor compositor, String to, float? from, TimeSpan duration, TimeSpan? delay, CompositionEasingFunction ease)
+ ///
+ /// Creates a instance with the given parameters to on a target element, using an expression animation
+ ///
+ /// The current instance used to create the animation
+ /// The optional starting value for the animation
+ /// A string that indicates the final value for the animation
+ /// The animation duration
+ /// The optional initial delay for the animation
+ /// The optional easing function for the animation
+ [PublicAPI]
+ [Pure, NotNull]
+ public static ScalarKeyFrameAnimation CreateScalarKeyFrameAnimation([NotNull] this Compositor compositor,
+ float? from, [NotNull] String to, TimeSpan duration, TimeSpan? delay, [CanBeNull] CompositionEasingFunction ease = null)
{
// Set duration and delay time
ScalarKeyFrameAnimation ani = compositor.CreateScalarKeyFrameAnimation();
@@ -74,8 +168,19 @@ public static ScalarKeyFrameAnimation CreateScalarKeyFrameAnimation(this Composi
return ani;
}
- // Create Vector2 animation from compositor
- public static Vector2KeyFrameAnimation CreateVector2KeyFrameAnimation(this Compositor compositor, Vector2 to, Vector2? from, TimeSpan duration, TimeSpan? delay, CompositionEasingFunction ease)
+ ///
+ /// Creates a instance with the given parameters to on a target element
+ ///
+ /// The current instance used to create the animation
+ /// The optional starting value for the animation
+ /// The final value for the animation
+ /// The animation duration
+ /// The optional initial delay for the animation
+ /// The optional easing function for the animation
+ [PublicAPI]
+ [Pure, NotNull]
+ public static Vector2KeyFrameAnimation CreateVector2KeyFrameAnimation([NotNull] this Compositor compositor,
+ Vector2? from, Vector2 to, TimeSpan duration, TimeSpan? delay, [CanBeNull] CompositionEasingFunction ease = null)
{
// Set duration and delay time
Vector2KeyFrameAnimation ani = compositor.CreateVector2KeyFrameAnimation();
@@ -88,8 +193,19 @@ public static Vector2KeyFrameAnimation CreateVector2KeyFrameAnimation(this Compo
return ani;
}
- // Create Vector2 expression animation from compositor
- public static Vector2KeyFrameAnimation CreateVector2KeyFrameAnimation(this Compositor compositor, String to, Vector2? from, TimeSpan duration, TimeSpan? delay, CompositionEasingFunction ease)
+ ///
+ /// Creates a instance with the given parameters to on a target element, using an expression animation
+ ///
+ /// The current instance used to create the animation
+ /// The optional starting value for the animation
+ /// A string that indicates the final value for the animation
+ /// The animation duration
+ /// The optional initial delay for the animation
+ /// The optional easing function for the animation
+ [PublicAPI]
+ [Pure, NotNull]
+ public static Vector2KeyFrameAnimation CreateVector2KeyFrameAnimation([NotNull] this Compositor compositor,
+ Vector2? from, [NotNull] String to, TimeSpan duration, TimeSpan? delay, [CanBeNull] CompositionEasingFunction ease = null)
{
// Set duration and delay time
Vector2KeyFrameAnimation ani = compositor.CreateVector2KeyFrameAnimation();
@@ -102,8 +218,19 @@ public static Vector2KeyFrameAnimation CreateVector2KeyFrameAnimation(this Compo
return ani;
}
- // Create Vector3 animation from compositor
- public static Vector3KeyFrameAnimation CreateVector3KeyFrameAnimation(this Compositor compositor, Vector3 to, Vector3? from, TimeSpan duration, TimeSpan? delay, CompositionEasingFunction ease)
+ ///
+ /// Creates a instance with the given parameters to on a target element
+ ///
+ /// The current instance used to create the animation
+ /// The optional starting value for the animation
+ /// The final value for the animation
+ /// The animation duration
+ /// The optional initial delay for the animation
+ /// The optional easing function for the animation
+ [PublicAPI]
+ [Pure, NotNull]
+ public static Vector3KeyFrameAnimation CreateVector3KeyFrameAnimation([NotNull] this Compositor compositor,
+ Vector3? from, Vector3 to, TimeSpan duration, TimeSpan? delay, [CanBeNull] CompositionEasingFunction ease = null)
{
// Set duration and delay time
Vector3KeyFrameAnimation ani = compositor.CreateVector3KeyFrameAnimation();
@@ -116,8 +243,19 @@ public static Vector3KeyFrameAnimation CreateVector3KeyFrameAnimation(this Compo
return ani;
}
- // Create Vector3 expression animation from compositor
- public static Vector3KeyFrameAnimation CreateVector3KeyFrameAnimation(this Compositor compositor, String to, Vector3? from, TimeSpan duration, TimeSpan? delay, CompositionEasingFunction ease)
+ ///
+ /// Creates a instance with the given parameters to on a target element, using an expression animation
+ ///
+ /// The current instance used to create the animation
+ /// The optional starting value for the animation
+ /// A string that indicates the final value for the animation
+ /// The animation duration
+ /// The optional initial delay for the animation
+ /// The optional easing function for the animation
+ [PublicAPI]
+ [Pure, NotNull]
+ public static Vector3KeyFrameAnimation CreateVector3KeyFrameAnimation([NotNull] this Compositor compositor,
+ Vector3? from, [NotNull] String to, TimeSpan duration, TimeSpan? delay, [CanBeNull] CompositionEasingFunction ease = null)
{
// Set duration and delay time
Vector3KeyFrameAnimation ani = compositor.CreateVector3KeyFrameAnimation();
@@ -129,5 +267,7 @@ public static Vector3KeyFrameAnimation CreateVector3KeyFrameAnimation(this Compo
if (from.HasValue) ani.InsertKeyFrame(0, from.Value);
return ani;
}
+
+ #endregion
}
}
diff --git a/UICompositionAnimations/CompositionExtensions.cs b/UICompositionAnimations/CompositionExtensions.cs
index 32e9ee6..77f23f9 100644
--- a/UICompositionAnimations/CompositionExtensions.cs
+++ b/UICompositionAnimations/CompositionExtensions.cs
@@ -73,7 +73,7 @@ private static Task ManageCompositionFadeAnimationAsync(this UIElement element,
else delay = null;
// Get the opacity animation
- ScalarKeyFrameAnimation opacityAnimation = visual.Compositor.CreateScalarKeyFrameAnimation(endOp, startOp, duration, delay, ease);
+ ScalarKeyFrameAnimation opacityAnimation = visual.Compositor.CreateScalarKeyFrameAnimation(startOp, endOp, duration, delay, ease);
// Close the batch and manage its event
CompositionScopedBatch batch = visual.Compositor.CreateScopedBatch(CompositionBatchTypes.Animation);
@@ -144,7 +144,7 @@ public static void SetCompositionFadeImplicitAnimation(this FrameworkElement ele
// Get the opacity animation
CompositionAnimationGroup group = visual.Compositor.CreateAnimationGroup();
- ScalarKeyFrameAnimation opacityAnimation = visual.Compositor.CreateScalarKeyFrameAnimation(end, start, duration, delay, ease);
+ ScalarKeyFrameAnimation opacityAnimation = visual.Compositor.CreateScalarKeyFrameAnimation(start, end, duration, delay, ease);
opacityAnimation.Target = "Opacity";
group.Add(opacityAnimation);
@@ -195,10 +195,10 @@ private static Task ManageCompositionFadeSlideAnimationAsync(this UIElement elem
CompositionScopedBatch batch = visual.Compositor.CreateScopedBatch(CompositionBatchTypes.Animation);
// Get the opacity the animation
- ScalarKeyFrameAnimation opacityAnimation = visual.Compositor.CreateScalarKeyFrameAnimation(endOp, startOp, durationOp, delay, ease);
+ ScalarKeyFrameAnimation opacityAnimation = visual.Compositor.CreateScalarKeyFrameAnimation(startOp, endOp, durationOp, delay, ease);
// Offset animation
- Vector3KeyFrameAnimation offsetAnimation = visual.Compositor.CreateVector3KeyFrameAnimation(endOffset, initialOffset, durationSlide, delay, ease);
+ Vector3KeyFrameAnimation offsetAnimation = visual.Compositor.CreateVector3KeyFrameAnimation(initialOffset, endOffset, durationSlide, delay, ease);
// Close the batch and manage its event
TaskCompletionSource