Join egghead, unlock knowledge.

Want more egghead? It's 45% off for a limited time only!

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

Unlock All Content for 45% Off

Already subscribed? Sign In

Save 45% for a limited time.

Get access to all courses and lessons on egghead today.


    Animate a Sequence of React Native Animations with Animated.sequence

    Jason BrownJason Brown

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

    react-nativeReact Native


    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


    00:00 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.

    00:20 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.

    00:57 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.

    01:19 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.