Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    Animate Multiple Animations at the Same Time with Animated.parallel

    Jason BrownJason Brown
    react-nativeReact Native
    0.35 - 0.39

    In this lesson we'll use Animated.parallel to animate multiple Animated.timing and Animated.spring animations at the same time.



    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson




    We'll start by importing Animated from React Native. Next, we'll create a componentWillMount life cycle method, then we'll create two animated values. this.animatedValue1 = new Animated.Value which will set the default value of 0And, this.animatedValue2, which will be a default value of one.

    Next, we'll set up our styles by creating a variable called animatedStyles, which we'll assign it object with the property transform, which takes an array. Our first transform, we'll translate Y, and we'll give it this.animatedValue1, and our second will be scale, which we'll give our second animation this.animatedValue2.

    Then we'll play our new style, but first we need to change our regular view to an Animated.View, and then, give it our new style. We'll create a componentWillMount life cycle method, and use Animated.Parallel, which takes an array of multiple animations. We'll add Animated.timing, and give it this.animatedValue1, and animate to 500 over the course of 300 milliseconds. Then, our second animation, we'll roll in Animated.Spring, we have this.animatedValue2, and spring to 3.

    Now, if we call Start on our Parallel, and refresh our emulator, we can see that it translated Y to 500 over 300 milliseconds, and scaled to 3 at the same time.