Animate a Sequence of React Native Animations with Animated.sequence

Jason Brown
InstructorJason Brown
Share this video with your friends

Social Share Links

Send Tweet
Published 7 years ago
Updated 5 years ago

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

[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.

egghead
egghead
~ 2 hours ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today