3 changed files with 55 additions and 0 deletions
@ -0,0 +1,35 @@ |
|||||
|
<UserControl |
||||
|
xmlns="https://github.com/avaloniaui" |
||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
|
x:Class="RenderDemo.Pages.SpringAnimationsPage" |
||||
|
MaxWidth="600"> |
||||
|
<UserControl.Resources> |
||||
|
<SpringEasing x:Key="SpringEasing" Mass="1" Stiffness="2000" Damping="20" InitialVelocity="0" /> |
||||
|
</UserControl.Resources> |
||||
|
<UserControl.Styles> |
||||
|
<Style Selector="Border.spring"> |
||||
|
<Style.Animations> |
||||
|
<Animation Duration="0:0:0.900" |
||||
|
IterationCount="Infinite" |
||||
|
PlaybackDirection="Normal" |
||||
|
Easing="{DynamicResource SpringEasing}"> |
||||
|
<KeyFrame Cue="0%" KeySpline=""> |
||||
|
<Setter Property="TranslateTransform.X" Value="-300"/> |
||||
|
</KeyFrame> |
||||
|
<KeyFrame Cue="100%"> |
||||
|
<Setter Property="TranslateTransform.X" Value="0" /> |
||||
|
</KeyFrame> |
||||
|
</Animation> |
||||
|
</Style.Animations> |
||||
|
</Style> |
||||
|
</UserControl.Styles> |
||||
|
<Grid> |
||||
|
<Border Classes="spring" Background="Red" Width="50" Height="50"> |
||||
|
<Border.RenderTransform> |
||||
|
<TransformGroup> |
||||
|
<TranslateTransform /> |
||||
|
</TransformGroup> |
||||
|
</Border.RenderTransform> |
||||
|
</Border> |
||||
|
</Grid> |
||||
|
</UserControl> |
||||
@ -0,0 +1,17 @@ |
|||||
|
using Avalonia.Controls; |
||||
|
using Avalonia.Markup.Xaml; |
||||
|
|
||||
|
namespace RenderDemo.Pages; |
||||
|
|
||||
|
public class SpringAnimationsPage : UserControl |
||||
|
{ |
||||
|
public SpringAnimationsPage() |
||||
|
{ |
||||
|
InitializeComponent(); |
||||
|
} |
||||
|
|
||||
|
private void InitializeComponent() |
||||
|
{ |
||||
|
AvaloniaXamlLoader.Load(this); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue