-
Notifications
You must be signed in to change notification settings - Fork 718
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(animation): not defaulting starting value from animated value
- Loading branch information
Showing
7 changed files
with
229 additions
and
22 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
src/Uno.UI.RuntimeTests/Extensions/StoryboardExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Media.Animation; | ||
|
||
namespace Uno.UI.RuntimeTests.Extensions; | ||
|
||
internal static class StoryboardExtensions | ||
{ | ||
public static void Begin(this Timeline timeline) | ||
{ | ||
var storyboard = new Storyboard { Children = { timeline } }; | ||
|
||
storyboard.Begin(); | ||
} | ||
|
||
public static async Task RunAsync(this Timeline timeline, TimeSpan? timeout, bool throwsException = false) | ||
{ | ||
var storyboard = new Storyboard { Children = { timeline } }; | ||
|
||
await storyboard.RunAsync(timeout, throwsException); | ||
} | ||
|
||
public static async Task RunAsync(this Storyboard storyboard, TimeSpan? timeout = null, bool throwsException = false) | ||
{ | ||
var tcs = new TaskCompletionSource<bool>(); | ||
void OnCompleted(object sender, object e) | ||
{ | ||
tcs.SetResult(true); | ||
storyboard.Completed -= OnCompleted; | ||
} | ||
|
||
storyboard.Completed += OnCompleted; | ||
storyboard.Begin(); | ||
|
||
if (timeout is { }) | ||
{ | ||
if (await Task.WhenAny(tcs.Task, Task.Delay(timeout.Value)) != tcs.Task) | ||
{ | ||
if (throwsException) | ||
{ | ||
throw new TimeoutException($"Timeout waiting for the storyboard to complete: {timeout}ms"); | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
await tcs.Task; | ||
} | ||
} | ||
|
||
public static TTimeline BindTo<TTimeline>(this TTimeline timeline, DependencyObject target, string property) | ||
where TTimeline : Timeline | ||
{ | ||
Storyboard.SetTarget(timeline, target); | ||
Storyboard.SetTargetProperty(timeline, property); | ||
|
||
return timeline; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters