Looping Lottie Animations Only Once

I was wondering how I can run a Lottie animation only once since it is looping by default.
Here is a link to the code I am trying to modify: https://docs.expo.io/versions/latest/sdk/lottie.html

Thanks.

Hey @airomo123,

Iā€™m a bit confused. The animation does only play once in the Lottie example. :thinking:

Adam

I use

  startLottieAnim(anim) {
    this.lottieAnim = anim;
    if (anim) {
      this.lottieAnim.play();
    }
  }

 <Lottie
    ref={c => this.startLottieAnim(c)}              
    style={{
      width: 400 - 100,
      height: 800 - 100
     }}
    source={require('../../../assets/superjump05_json.json')}  // eslint-disable-line
 />

and the animation is also looping.

1 Like

Hey @gregt,

It looks like there is a loop prop on the Lottie API http://airbnb.io/lottie/react-native/props.html so just set that to false.

Cheers,

Adam

2 Likes

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.