|
@@ -26,14 +26,14 @@ namespace Avalonia.Animation
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// The time span of each frame.
|
|
/// The time span of each frame.
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
- private static readonly TimeSpan Tick = TimeSpan.FromSeconds(1.0 / FramesPerSecond);
|
|
|
|
|
|
|
+ internal static readonly TimeSpan FrameTick = TimeSpan.FromSeconds(1.0 / FramesPerSecond);
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// Initializes static members of the <see cref="Timing"/> class.
|
|
/// Initializes static members of the <see cref="Timing"/> class.
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
static Timing()
|
|
static Timing()
|
|
|
{
|
|
{
|
|
|
- var globalTimer = Observable.Interval(Tick, AvaloniaScheduler.Instance);
|
|
|
|
|
|
|
+ var globalTimer = Observable.Interval(FrameTick, AvaloniaScheduler.Instance);
|
|
|
|
|
|
|
|
AnimationStateTimer = globalTimer
|
|
AnimationStateTimer = globalTimer
|
|
|
.Select(_ =>
|
|
.Select(_ =>
|
|
@@ -72,10 +72,9 @@ namespace Avalonia.Animation
|
|
|
/// Gets the animation timer.
|
|
/// Gets the animation timer.
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
/// <remarks>
|
|
/// <remarks>
|
|
|
- /// The animation timer increments usually 60 times per second as
|
|
|
|
|
|
|
+ /// The animation timer triggers usually at 60 times per second or as
|
|
|
/// defined in <see cref="FramesPerSecond"/>.
|
|
/// defined in <see cref="FramesPerSecond"/>.
|
|
|
- /// The parameter passed to a subsciber is the number of frames since the animation system was
|
|
|
|
|
- /// initialized.
|
|
|
|
|
|
|
+ /// The parameter passed to a subsciber is the current playstate of the animation.
|
|
|
/// </remarks>
|
|
/// </remarks>
|
|
|
internal static IObservable<PlayState> AnimationStateTimer
|
|
internal static IObservable<PlayState> AnimationStateTimer
|
|
|
{
|
|
{
|
|
@@ -96,30 +95,6 @@ namespace Avalonia.Animation
|
|
|
get;
|
|
get;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /// <summary>
|
|
|
|
|
- /// Gets a timer that fires every frame for the specified duration with delay.
|
|
|
|
|
- /// This timer's running state can be changed via <see cref="SetGlobalPlayState"/> method.
|
|
|
|
|
- /// </summary>
|
|
|
|
|
- /// <returns>
|
|
|
|
|
- /// An observable that notifies the subscriber of the progress along the animation.
|
|
|
|
|
- /// </returns>
|
|
|
|
|
- /// <remarks>
|
|
|
|
|
- /// The parameter passed to the subscriber is the progress along the animation, with
|
|
|
|
|
- /// 0 being the start and 1 being the end. The observable is guaranteed to fire 0
|
|
|
|
|
- /// immediately on subscribe and 1 at the end of the duration.
|
|
|
|
|
- /// </remarks>
|
|
|
|
|
- public static IObservable<double> GetAnimationsTimer(Animatable control, TimeSpan duration, TimeSpan delay)
|
|
|
|
|
- {
|
|
|
|
|
- var startTime = control._animationTime;
|
|
|
|
|
- var _duration = (ulong)(duration.Ticks / Tick.Ticks);
|
|
|
|
|
- var endTime = startTime + _duration;
|
|
|
|
|
- return control.AnimatableTimer
|
|
|
|
|
- .TakeWhile(x => x < endTime)
|
|
|
|
|
- .Select(x => (double)(x - startTime) / _duration)
|
|
|
|
|
- .StartWith(0.0)
|
|
|
|
|
- .Concat(Observable.Return(1.0));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// Gets a timer that fires every frame for the specified duration with delay.
|
|
/// Gets a timer that fires every frame for the specified duration with delay.
|
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -134,7 +109,7 @@ namespace Avalonia.Animation
|
|
|
public static IObservable<double> GetTransitionsTimer(Animatable control, TimeSpan duration, TimeSpan delay = default(TimeSpan))
|
|
public static IObservable<double> GetTransitionsTimer(Animatable control, TimeSpan duration, TimeSpan delay = default(TimeSpan))
|
|
|
{
|
|
{
|
|
|
var startTime = _transitionsFrameCount;
|
|
var startTime = _transitionsFrameCount;
|
|
|
- var _duration = (ulong)(duration.Ticks / Tick.Ticks);
|
|
|
|
|
|
|
+ var _duration = (ulong)(duration.Ticks / FrameTick.Ticks);
|
|
|
var endTime = startTime + _duration;
|
|
var endTime = startTime + _duration;
|
|
|
|
|
|
|
|
return TransitionsTimer
|
|
return TransitionsTimer
|