- ExtZGholson
- Posts: 22
- Joined:
Lottie animations
Hello,
We are making a native app and will be utilizing the Lottie plugin for our animations as found here: https://github.com/Noesis/Lottie-Noesis
Do we have more examples on how to export Xaml files for this with the parameters?
Is there a way to tell the animations to play / pause etc via code behind or xaml?
Thank you
We are making a native app and will be utilizing the Lottie plugin for our animations as found here: https://github.com/Noesis/Lottie-Noesis
Do we have more examples on how to export Xaml files for this with the parameters?
Is there a way to tell the animations to play / pause etc via code behind or xaml?
Thank you
-
sfernandez
Site Admin
- Posts: 3154
- Joined:
Re: Lottie animations
Current version of the lottie plugin can generate two types of xaml files:
1. To generate a xaml with a root Canvas with a single Storyboard animation that is automatically fired when the Canvas is added to the UI tree (Loaded event).
2. To generate a xaml with a ResourceDictionary containing a ControlTemplate. The template contains also a single Storyboard animation that will be automatically fired when the template gets applied to a control.
If you want to manually handle when animations will be launched you can use the first option, comment the EventTrigger, and find the Storyboard resource in the canvas root:
Then you can play/pause the animation whenever you want in code behind:
We have plans to improve the lottie plugin to allow After Effect animations to be labelled and generate xamls with different visual states that could be set from code-behind or xaml:
1. To generate a xaml with a root Canvas with a single Storyboard animation that is automatically fired when the Canvas is added to the UI tree (Loaded event).
Code: Select all
json2xaml.py lottie.json lottie.xaml
Code: Select all
json2xaml.py --template lottie lottie.json lottie.xaml
Code: Select all
Storyboard* anims = canvas->FindResource<Storyboard>("Anims");
Code: Select all
anims->Begin(canvas, true /*isControllable*/);
anims->Pause(canvas);
anims->Resume(canvas);
anims->Stop(canvas);
Code: Select all
control->GoToState("Fire");
Code: Select all
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity">
<Grid.Resources>
<ResourceDictionary Source="lottie.xaml"/>
</Grid.Resources>
<i:Interaction.Triggers>
<i:EventTrigger EventName="Loaded">
<i:GoToState StateName="Fire" TargetName="control"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<Control x:Name="control" Template="{StaticResource lottie}"/>
</Grid>
Who is online
Users browsing this forum: No registered users and 2 guests