The Tokay Gecko Versus the Vietnam Veteran

When I was in my late teens, I went off to dog grooming school, graduated, and got a job as a groomer in the back of Pet Palace. The year was 1988 and I was eager to start building my business and…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Lottie Animation Workflow Part 2

Once the project is created, we can open the app source in an editor and look for App.js, which should contain the following code:

Now that Lottie is imported we can put the animation into the project. Take the animation we created in part 1 and place it in the assets folder in the file structure:

The animation is named ‘data.json’

Finally, all we need to do to display the animation is configure it into the Lottie component we imported above.

If you run the code in the iOS simulator (in Expo XDE, choose device > ‘Open on iOS Simulator’) you will see that the animation plays but isn’t positioned correctly and it stops after it plays the full animation one time.

To fix this, let’s give it some styles and add the loop property in the code:

Now you can see we have a nice centered animation that loops:

That is a basic implementation of importing a Lottie animation and displaying it in a React Native Expo app, but Lottie can do a lot more and just as a quick example, let’s add a toggle to the loop prop so we can start/stop the animation on demand:

So, there you have it. We have created an animation from scratch and rendered it in a mobile app. Next time we’ll go over some more advanced features that Lottie offers. If there is anything specific you’d like to see, add a comment below.

Add a comment

Related posts:

On Leadership

The floods in Texas and Makurdi this week resurrected a debate inside me. For a long time, I have heard people complain that Nigerians are the problem with Nigeria; that deep down we are corrupt and…

Tree Cycle

Leaves at their brightest. “Tree Cycle” is published by Soulez Chille in The Story Hall.

Here Is How To Gain The Courage To Follow Your Purpose

It started as a normal “How was your day conversation”, but I decided to take it to the next level and asked her a couple of question that I’d never asked her before. She was quiet for so long that I…