From b3ebfa574865a5aee54594e6dd48ca38e11e0713 Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Thu, 2 Aug 2018 02:03:14 +0800 Subject: [PATCH] Add the global frame count to AnimationStateTimer. --- src/Avalonia.Animation/Timing.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Animation/Timing.cs b/src/Avalonia.Animation/Timing.cs index 10d65cca7f..3eddc0ac26 100644 --- a/src/Avalonia.Animation/Timing.cs +++ b/src/Avalonia.Animation/Timing.cs @@ -16,6 +16,7 @@ namespace Avalonia.Animation public static class Timing { static ulong _transitionsFrameCount; + static long _tickStartTimeStamp; static PlayState _globalState = PlayState.Run; /// @@ -33,12 +34,16 @@ namespace Avalonia.Animation /// static Timing() { + + _tickStartTimeStamp = Stopwatch.GetTimestamp(); + var globalTimer = Observable.Interval(FrameTick, AvaloniaScheduler.Instance); AnimationStateTimer = globalTimer .Select(_ => { - return _globalState; + return (_globalState, (Stopwatch.GetTimestamp() - _tickStartTimeStamp) + / (Stopwatch.Frequency / FramesPerSecond)); }) .Publish() .RefCount(); @@ -76,7 +81,7 @@ namespace Avalonia.Animation /// defined in . /// The parameter passed to a subsciber is the current playstate of the animation. /// - internal static IObservable AnimationStateTimer + internal static IObservable<(PlayState, long)> AnimationStateTimer { get; }