Fireship · @fireship
Beautiful Router Animations with Angular
Uploaded February 11, 2019 · Length 10:01
Summary
Implementing router animations in Angular for a polished app experience, including fade-in, slide, and keyframe animations.
- angular router animations
- beautiful animations
- angular animations tutorial
- router transitions
- angular animation examples
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
[Music]
- 0:07
an easy way to make your app more
- 0:08
polished is to implement animations
- 0:10
between router transitions today's video
- 0:12
is a complete guide to router animations
- 0:13
in angular and we'll build four
- 0:15
different styles that range from a
- 0:16
simple fadein to a complex key frame
- 0:18
sequence of animations if you're new
- 0:20
here like And subscribe and grab the
- 0:21
full source code from fireship iio and
- 0:24
before we get started I want to give a
- 0:25
quick shout out to the deal crunch app
- 0:26
which is a real estate app available on
- 0:28
IOS and Android it was built by one of
- 0:30
our Pro members and is a great example
- 0:31
of what you can do with angular and
- 0:33
ionic now let's first start by looking
- 0:35
at the actual animations that we'll
- 0:37
build in this video the first one is
- 0:38
just a simple fade in which is applied
- 0:40
to every single route in the app the
- 0:42
second animation is a slide from left to
- 0:44
right and it determines which direction
- 0:46
to slide Based on data that we pass in
- 0:48
through the router configuration the
- 0:50
third one is slightly more complex and
- 0:51
adds in Transformations so we can make
- 0:53
the page kind of rotate in from the top
- 0:55
corners and the fourth and final one
- 0:57
uses key frames to create a sequence of
- 0:59
style Chang es for example the new page
- 1:01
comes in from the bottom and bumps the
- 1:03
old page off and it spins and scales out
- 1:05
of the screen I'm starting off here in
- 1:06
my angular 7 app and you'll notice that
- 1:08
I've generated a handful of components
- 1:10
here just so we have something to
- 1:11
actually route to and you don't need to
- 1:13
do anything special with these
- 1:14
components whatsoever so we won't even
- 1:16
bother looking at them in this video
- 1:18
then the other thing we'll do in the app
- 1:19
module is import the browser animations
- 1:21
module and add it to the Imports array
- 1:24
from there we'll go into the HTML and
- 1:25
the app component and create a main
- 1:27
element and then Define an animation
- 1:29
called route animations and then we'll
- 1:31
point this to a method called prepare
- 1:33
route which we'll Define in a second and
- 1:34
its job is to determine which animation
- 1:36
to apply to a given route now inside of
- 1:38
this element we'll Define our router
- 1:40
outlet and then give it a template
- 1:41
variable name of outlet as well now
- 1:43
whenever a route changes we can animate
- 1:45
the content inside of the router Outlet
- 1:48
then you can see above the outlet I have
- 1:49
my actual navigation bar so this will
- 1:51
stay fixed and not be animated between
- 1:53
the route changes now I'll jump into the
- 1:54
app component typescript and you'll see
- 1:56
that I'm importing these animations
- 1:58
which we have not yet defined I simp


