Code Monkey home page Code Monkey logo

Comments (7)

indivisable avatar indivisable commented on May 17, 2024

It works for me when using the imperative API


import React from 'react';
import Animation from 'lottie-react-native';

export default class BasicExample extends React.Component {
  componentDidMount() {
    this.animation.play();
  }

  render() {
    return (
      <Animation
        loop={true}
        ref={animation => { this.animation = animation; }}
        style={{
          width: 200,
          height: 200,
        }}
        source={require('../path/to/animation.json')}
      />
    );
  }
}

from lottie-react-native.

baires avatar baires commented on May 17, 2024

I didn't try the imperative API, just pointing that looping on the component API isn't working

from lottie-react-native.

lelandrichardson avatar lelandrichardson commented on May 17, 2024

At the moment loop is only applicable to the imperative API. I'm not quite sure how it would work with the Animated API, since the animation progress is controlled by an animated value (which you would be able to loop yourself if you wanted, though it's not straight-forward).

I'm happy to take suggestions on how this could/should work

from lottie-react-native.

baires avatar baires commented on May 17, 2024

If there was a callback when the animation ends something like onAnimationComplete we can reset the animation again.

from lottie-react-native.

lelandrichardson avatar lelandrichardson commented on May 17, 2024

if you're using the Animated API, this callback already exists. You would animate from 0 -> 1, and then reset

from lottie-react-native.

lelandrichardson avatar lelandrichardson commented on May 17, 2024

Though, I do think that the Animated API could use a loop API. I know I had talked to vjeux about this at some point. Perhaps it's time to make a PR

from lottie-react-native.

baires avatar baires commented on May 17, 2024

Sounds good, thanks for your feedback!

from lottie-react-native.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.