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 a Sequence of React Native Animations with Animated.sequence

    react-nativeReact Native
    0.35 - 0.39

    In this lesson we'll use Animated.sequence to play multiple Animated.timing, and Animated.spring animations one after another.



    Become a Member to view code

    You must be a Pro 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
    orLog In




    We'll start by importing Animated from React Native. Then we'll create our componentWillMount life cycle method. We'll start with two animated values. We'll create them at this.animated (value1) equals a new animated value with a default value of 0This.animated(value2) and we'll create animated value and assign a default value of 1.

    Then we'll create a variable called animatedstyle, assign it an object with the property of transform, which is an array, which takes a series of objects. Our first transform object will translate y, which we'll give it this.animated(value1). Our second will be scale, which we'll give this.animated(value2). Then we'll change our regular view to an animated view and then apply our new animated style to that view.

    Now we'll create a componentToMount life cycle method. We'll use animated.sequence, which is a function that takes an array. Then we'll create an animated.timing and pass in this.animated(value1). We'll animate to 150 over the course of a thousand milliseconds.

    Then we'll create an animated.spring and pass on this.animated(value2) and animate to 3. Then we'll create another animated.timing and animate this.animated(value1) back to 0over another thousand milliseconds. Then animate another animated.spring on this.animated(value2) to 05. Then we'll call start on our sequence, refresh our emulator, and see that each animation played one after the other.