Home > Blockchain >  How to play lottie starting at the end, playing backwards to the start of the animation in xamarin?
How to play lottie starting at the end, playing backwards to the start of the animation in xamarin?

Time:12-08

Is there any option to play lottie starting at the end, playing backwards to the start of the animation in xamarin? From code behind in c#

<lottie:AnimationView x:Name="lottie" AutoPlay="False" Animation="heartreaction.json"  />

Clicked

private void super_Clicked(object sender, EventArgs e)
    {
        lottie.PlayAnimation();
        //Instead play it backwards
    }

CodePudding user response:

Use the direction value equals to -1.

<lottie:AnimationView x:Name="lottie" AutoPlay="False" Animation="heartreaction.json" direction="-1" />

check this link for more details: https://github.com/LottieFiles/lottie-player/issues/40

You could use js to update dom props after onClick event.

CodePudding user response:

If you use SKLottieView, you could set RepeatMode="Reverse" to make it. You could add Skiasharp.Extended.UI.Forms Nuget first.

The following code is an example:

<skia:SKLottieView 
    HorizontalOptions="CenterAndExpand"
    VerticalOptions="CenterAndExpand"
    x:Name="myanimatedview"
    Source="dotnetbot.json"
    HeightRequest="300"
    WidthRequest="300"
    RepeatCount="-1"
    IsAnimationEnabled="True"
    RepeatMode="Reverse"/>

Or set it in code behind cs file:

myanimatedview.RepeatMode = SKLottieRepeatMode.Reverse;

Hope it works for you.

  • Related