Added ContextMenu/Flyout animations. Added platform services. Use bitmap cache for all views.
This commit is contained in:
58
Harmonia.UI/Animations/Animations.cs
Normal file
58
Harmonia.UI/Animations/Animations.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Animation;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Styling;
|
||||
using System;
|
||||
|
||||
namespace Harmonia.UI.Animations
|
||||
{
|
||||
public static class Animations
|
||||
{
|
||||
public static Animation SlideIn(Point start, Point end, long duration = 200)
|
||||
{
|
||||
return new()
|
||||
{
|
||||
Duration = TimeSpan.FromMilliseconds(duration),
|
||||
Children =
|
||||
{
|
||||
new KeyFrame
|
||||
{
|
||||
Cue = new Cue(0f),
|
||||
Setters =
|
||||
{
|
||||
new Setter(Visual.OpacityProperty, 0.0),
|
||||
new Setter(TranslateTransform.XProperty, start.X),
|
||||
new Setter(TranslateTransform.YProperty, start.Y)
|
||||
}
|
||||
},
|
||||
new KeyFrame
|
||||
{
|
||||
Cue = new Cue(1f),
|
||||
Setters =
|
||||
{
|
||||
new Setter(Visual.OpacityProperty, 1.0),
|
||||
new Setter(TranslateTransform.XProperty, end.X),
|
||||
new Setter(TranslateTransform.YProperty, end.Y)
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static Animation SlideFromRight(double offSet, long duration = 200)
|
||||
{
|
||||
Point start = new(-offSet, 0);
|
||||
Point end = new(0, 0);
|
||||
|
||||
return SlideIn(start, end, duration);
|
||||
}
|
||||
|
||||
public static Animation SlideToRight(double offSet, long duration = 200)
|
||||
{
|
||||
Point start = new(0, 0);
|
||||
Point end = new(offSet, 0);
|
||||
|
||||
return SlideIn(start, end, duration);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user