feat:Add several predefined SizeAnimations.
This commit is contained in:
@@ -41,9 +41,7 @@
|
||||
ItemsSource="{Binding MenuItems}"
|
||||
SelectedItem="{Binding SelectedMenuItem}"
|
||||
SubMenuBinding="{Binding Children}"
|
||||
u:SizeAnimationHelper.TriggerAvaloniaProperty="{x:Static u:NavMenu.IsHorizontalCollapsedProperty}"
|
||||
u:SizeAnimationHelper.CreateAnimation="{x:Static views:NavMenuDemo.NavMenuAnimation}"
|
||||
u:SizeAnimationHelper.EnableWHAnimation="True">
|
||||
Classes="enable_animation">
|
||||
<u:NavMenu.Styles>
|
||||
<Style x:DataType="vm:MenuItem" Selector="u|NavMenuItem">
|
||||
<Setter Property="IsSeparator" Value="{Binding IsSeparator}" />
|
||||
|
||||
@@ -17,38 +17,4 @@ public partial class NavMenuDemo : UserControl
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public static SizeAnimationHelperAnimationGeneratorDelegate NavMenuAnimation { get; } =
|
||||
(_, oldDesiredSize, newDesiredSize) =>
|
||||
{
|
||||
if (oldDesiredSize.Width > newDesiredSize.Width)
|
||||
newDesiredSize = newDesiredSize.WithWidth(newDesiredSize.Width + 20);
|
||||
return new Animation
|
||||
{
|
||||
Duration = TimeSpan.FromMilliseconds(300),
|
||||
Easing = new CubicEaseInOut(),
|
||||
FillMode = FillMode.None,
|
||||
Children =
|
||||
{
|
||||
new KeyFrame
|
||||
{
|
||||
Cue = new Cue(0.0),
|
||||
Setters =
|
||||
{
|
||||
new Setter(WidthProperty, oldDesiredSize.Width),
|
||||
new Setter(HeightProperty, oldDesiredSize.Height)
|
||||
}
|
||||
},
|
||||
new KeyFrame
|
||||
{
|
||||
Cue = new Cue(1.0),
|
||||
Setters =
|
||||
{
|
||||
new Setter(WidthProperty, newDesiredSize.Width),
|
||||
new Setter(HeightProperty, newDesiredSize.Height)
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user