|
|
|
@ -6,6 +6,7 @@ using System.Collections.Generic; |
|
|
|
using System.Reactive.Threading.Tasks; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Avalonia.Media; |
|
|
|
using Avalonia.Styling; |
|
|
|
using Avalonia.VisualTree; |
|
|
|
|
|
|
|
namespace Avalonia.Animation |
|
|
|
@ -67,7 +68,7 @@ namespace Avalonia.Animation |
|
|
|
/// <returns>
|
|
|
|
/// A <see cref="Task"/> that tracks the progress of the animation.
|
|
|
|
/// </returns>
|
|
|
|
public async Task Start(IVisual from, IVisual to, bool forward) |
|
|
|
public async Task Start(Visual from, Visual to, bool forward) |
|
|
|
{ |
|
|
|
var tasks = new List<Task>(); |
|
|
|
var parent = GetVisualParent(from, to); |
|
|
|
@ -79,16 +80,69 @@ namespace Avalonia.Animation |
|
|
|
// in favor of XAML based transition for pages
|
|
|
|
if (from != null) |
|
|
|
{ |
|
|
|
|
|
|
|
var animation = new Animation |
|
|
|
{ |
|
|
|
new KeyFrame |
|
|
|
( |
|
|
|
new Setter |
|
|
|
{ |
|
|
|
Property = translateProperty, |
|
|
|
Value = 0 |
|
|
|
} |
|
|
|
) |
|
|
|
{ |
|
|
|
Cue = new Cue(0.0) |
|
|
|
}, |
|
|
|
new KeyFrame |
|
|
|
( |
|
|
|
new Setter |
|
|
|
{ |
|
|
|
Property = translateProperty, |
|
|
|
Value = forward ? -distance : distance |
|
|
|
} |
|
|
|
) |
|
|
|
{ |
|
|
|
Cue = new Cue(1.0) |
|
|
|
} |
|
|
|
}; |
|
|
|
animation.Duration = Duration; |
|
|
|
tasks.Add(animation.RunAsync(from)); |
|
|
|
} |
|
|
|
|
|
|
|
if (to != null) |
|
|
|
{ |
|
|
|
|
|
|
|
to.IsVisible = true; |
|
|
|
var animation = new Animation |
|
|
|
{ |
|
|
|
|
|
|
|
new KeyFrame |
|
|
|
( |
|
|
|
new Setter |
|
|
|
{ |
|
|
|
Property = translateProperty, |
|
|
|
Value = forward ? -distance : distance |
|
|
|
} |
|
|
|
) |
|
|
|
{ |
|
|
|
Cue = new Cue(0.0) |
|
|
|
}, |
|
|
|
new KeyFrame |
|
|
|
( |
|
|
|
new Setter |
|
|
|
{ |
|
|
|
Property = translateProperty, |
|
|
|
Value = 0 |
|
|
|
} |
|
|
|
) |
|
|
|
{ |
|
|
|
Cue = new Cue(1.0) |
|
|
|
}, |
|
|
|
}; |
|
|
|
animation.Duration = Duration; |
|
|
|
tasks.Add(animation.RunAsync(to)); |
|
|
|
} |
|
|
|
|
|
|
|
// FIXME: This is temporary until animations are fixed.
|
|
|
|
await Task.Delay(1); |
|
|
|
await Task.WhenAll(tasks); |
|
|
|
|
|
|
|
if (from != null) |
|
|
|
{ |
|
|
|
|