21 changed files with 111 additions and 130 deletions
@ -1,45 +0,0 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using System; |
|||
|
|||
namespace Avalonia.Animation |
|||
{ |
|||
/// <summary>
|
|||
/// Defines animation extension methods.
|
|||
/// </summary>
|
|||
public static class AnimationExtensions |
|||
{ |
|||
///// <summary>
|
|||
///// Returns a new <see cref="Avalonia.Animation.Transition"/> for the specified
|
|||
///// <see cref="AvaloniaProperty"/> using linear easing.
|
|||
///// </summary>
|
|||
///// <typeparam name="T">The type of the <see cref="AvaloniaProperty"/>.</typeparam>
|
|||
///// <param name="property">The property to animate.</param>
|
|||
///// <param name="milliseconds">The animation duration in milliseconds.</param>
|
|||
///// <returns>
|
|||
///// A <see cref="Avalonia.Animation.Transition"/> that can be added to the
|
|||
///// <see cref="Animatable.Transitions"/> collection.
|
|||
///// </returns>
|
|||
//public static Transition Transition<T>(this AvaloniaProperty<T> property, int milliseconds)
|
|||
//{
|
|||
// return Transition(property, TimeSpan.FromMilliseconds(milliseconds));
|
|||
//}
|
|||
|
|||
///// <summary>
|
|||
///// Returns a new <see cref="Avalonia.Animation.Transition"/> for the specified
|
|||
///// <see cref="AvaloniaProperty"/> using linear easing.
|
|||
///// </summary>
|
|||
///// <typeparam name="T">The type of the <see cref="AvaloniaProperty"/>.</typeparam>
|
|||
///// <param name="property">The property to animate.</param>
|
|||
///// <param name="duration">The animation duration.</param>
|
|||
///// <returns>
|
|||
///// A <see cref="Avalonia.Animation.Transition"/> that can be added to the
|
|||
///// <see cref="Animatable.Transitions"/> collection.
|
|||
///// </returns>
|
|||
//public static Transition Transition<T>(this AvaloniaProperty<T> property, TimeSpan duration)
|
|||
//{
|
|||
// return new Transition(property, duration, LinearEasing.For<T>());
|
|||
//}
|
|||
} |
|||
} |
|||
@ -1,56 +0,0 @@ |
|||
//// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
//// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
//using System;
|
|||
|
|||
//namespace Avalonia.Animation
|
|||
//{
|
|||
// /// <summary>
|
|||
// /// Tracks the progress of an animation.
|
|||
// /// </summary>
|
|||
// /// <typeparam name="T">The type of the value being animated./</typeparam>
|
|||
// public class Animation<T> : IObservable<T>, IDisposable
|
|||
// {
|
|||
// /// <summary>
|
|||
// /// The animation being tracked.
|
|||
// /// </summary>
|
|||
// private readonly IObservable<T> _inner;
|
|||
|
|||
// /// <summary>
|
|||
// /// The disposable used to cancel the animation.
|
|||
// /// </summary>
|
|||
// private readonly IDisposable _subscription;
|
|||
|
|||
// /// <summary>
|
|||
// /// Initializes a new instance of the <see cref="Animation{T}"/> class.
|
|||
// /// </summary>
|
|||
// /// <param name="inner">The animation observable being tracked.</param>
|
|||
// /// <param name="subscription">A disposable used to cancel the animation.</param>
|
|||
// public Animation(IObservable<T> inner, IDisposable subscription)
|
|||
// {
|
|||
// _inner = inner;
|
|||
// _subscription = subscription;
|
|||
// }
|
|||
|
|||
// /// <summary>
|
|||
// /// Cancels the animation.
|
|||
// /// </summary>
|
|||
// public void Dispose()
|
|||
// {
|
|||
// _subscription.Dispose();
|
|||
// }
|
|||
|
|||
// /// <summary>
|
|||
// /// Notifies the provider that an observer is to receive notifications.
|
|||
// /// </summary>
|
|||
// /// <param name="observer">The observer.</param>
|
|||
// /// <returns>
|
|||
// /// A reference to an interface that allows observers to stop receiving notifications
|
|||
// /// before the provider has finished sending them.
|
|||
// /// </returns>
|
|||
// public IDisposable Subscribe(IObserver<T> observer)
|
|||
// {
|
|||
// return _inner.Subscribe(observer);
|
|||
// }
|
|||
// }
|
|||
//}
|
|||
@ -0,0 +1,31 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using Avalonia.Metadata; |
|||
using System; |
|||
using System.Reactive.Linq; |
|||
|
|||
namespace Avalonia.Animation |
|||
{ |
|||
/// <summary>
|
|||
/// Transition class that handles <see cref="AvaloniaProperty"/> with <see cref="Point"/> types.
|
|||
/// </summary>
|
|||
public class PointTransition : Transition<Point> |
|||
{ |
|||
/// <inheritdocs/>
|
|||
public override IObservable<Point> DoTransition(IObservable<double> progress, Point oldValue, Point newValue) |
|||
{ |
|||
var deltaX = newValue.X - oldValue.Y; |
|||
var deltaY = newValue.X - oldValue.Y; |
|||
|
|||
return progress |
|||
.Select(p => |
|||
{ |
|||
var f = Easing.Ease(p); |
|||
var nX = f * deltaX + oldValue.X; |
|||
var nY = f * deltaY + oldValue.Y; |
|||
return new Point(nX, nY); |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using Avalonia.Metadata; |
|||
using System; |
|||
using System.Reactive.Linq; |
|||
|
|||
namespace Avalonia.Animation |
|||
{ |
|||
/// <summary>
|
|||
/// Transition class that handles <see cref="AvaloniaProperty"/> with <see cref="Thickness"/> types.
|
|||
/// </summary>
|
|||
public class ThicknessTransition : Transition<Thickness> |
|||
{ |
|||
/// <inheritdocs/>
|
|||
public override IObservable<Thickness> DoTransition(IObservable<double> progress, Thickness oldValue, Thickness newValue) |
|||
{ |
|||
var deltaL = newValue.Left - oldValue.Left; |
|||
var deltaT = newValue.Top - oldValue.Top; |
|||
var deltaR = newValue.Right - oldValue.Right; |
|||
var deltaB = newValue.Bottom - oldValue.Bottom; |
|||
|
|||
return progress |
|||
.Select(p => |
|||
{ |
|||
var f = Easing.Ease(p); |
|||
var nL = f * deltaL + oldValue.Left; |
|||
var nT = f * deltaT + oldValue.Right; |
|||
var nR = f * deltaR + oldValue.Top; |
|||
var nB = f * deltaB + oldValue.Bottom; |
|||
return new Thickness(nL, nT, nR, nB); |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue