Use Framer Motion initial Prop to Define the Beginning State of Animations

Will Johnson
InstructorWill Johnson
Share this video with your friends

Social Share Links

Send Tweet
Published 3 years ago
Updated 3 years ago

Add the initial prop to a motion component to tell Framer what state you want the element to be in when the page first loads. It will animate from that state to the state you declared in the animate prop.

Will Johnson: [0:00] If the animate prop is how we want the animation to end up, then the initial prop is how we want the animation to begin. Let's set our animation prop to y: . We want to end up at on the y-axis within the container.

[0:22] Let's add the initial prop. The initial prop takes in an object, just like the animate prop does. Let's say we want it to be y, and let's say -200 on the y-axis. Let's add this space and then save. Then we reload the page. As you see, it starts -200 degrees and comes all the way down to y of .

[0:51] Let's add something else in here. Let's say opacity because it's making a nice little moving fade. Let's say opacity: . You don't want it to be visible, initially, when the page loads. Let's animate the opacity to 1. We want it to be solid by the time the animation is finished. Then we save. As you see, it dropped down and faded in.

[1:29] A good way to remember this is, initial is how it started, and animate is how it ended.

egghead
egghead

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