⚠️ This lesson is retired and might contain outdated information.

Animate Between Angular States Using Transitions

John Lindquist
InstructorJohn Lindquist
Share this video with your friends

Social Share Links

Send Tweet
Published 8 years ago
Updated a month ago

The foundation of animation in Angular is using transitions to move from one state to another state. Transitions bring in the concept of time and how long it should take to go from one state to the next while they almost magically calculate the difference in values over time between the CSS properties of each state.

[00:00] Now, we can make a second button here. We'll call this onStopClick(), call this stop. Create a method called onStopClick() and this .signal = stop. Now we'll have a go, stop, go, stop button. What we can do between these two states is we can define what's called a transition between the states.

[00:24] The way we define this transition is with a string that represents the from and it moves to the to. We're saying from any state and moving to any state. We want to animate for 500 milliseconds. Hit save and you'll see we go from Go to Stop, Go to Stop, and it's smoothly animating between red and green. I can even add in more properties here, like height 100 pixels, height 50 pixels.

[01:00] Now when it starts, you'll see it goes from nothing to Stop, and then Go, and Stop and Go, and smoothly animating between those states and properties.

egghead
egghead
~ 2 minutes 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