Fireship · @fireship
Learn Angular Animations with 5 Examples
Uploaded July 24, 2017 · Length 7:02
Summary
Learn Angular animations with 5 examples, including fade-in/fade-out, photo gallery, and list animations, covering concepts like triggers, transitions, and keyframes.
- angular animations
- angular 4.2
- css3 animations
- web animations api
- animation examples
- angular tutorials
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
animation is often the x-factor that
- 0:02
separates remarkable apps from ordinary
- 0:05
apps in this episode I'm going to cover
- 0:07
five different concepts related to
- 0:09
angular animations including a few new
- 0:11
concepts that were introduced in angular
- 0:13
4.2 angular animations are built on the
- 0:17
web animations API which is very similar
- 0:20
to css3 animations if you're not
- 0:23
comfortable with animation at all I
- 0:25
recommend doing some practice with css3
- 0:27
first and then you'll be able to make
- 0:28
the most out of angular's animation
- 0:30
module the first step to get started is
- 0:34
to import the browser animation module
- 0:36
into whatever module you plan on using
- 0:38
animations in this first example I'm
- 0:41
going to create a fade-in fade-out
- 0:42
animation that will show some content in
- 0:45
a popover when a button is clicked we
- 0:47
import the methods we need from the
- 0:49
animation module and then we'll create a
- 0:51
boolean variable show that will
- 0:53
determine the visibility of the popover
- 0:55
I also create a getter called state name
- 0:58
which will return the boolean variable
- 1:00
as a string either show or hide which we
- 1:02
need when defining the animation itself
- 1:03
in the HTML we use animations by
- 1:07
prefixing the animation name with the @
- 1:10
symbol and then pass at the current
- 1:11
state of whatever variable we're going
- 1:14
to animate in this case the only
- 1:16
possible values will be show or hide and
- 1:18
then we add a button for the user to
- 1:20
toggle this variable the end result
- 1:24
should look something like this it's
- 1:25
just a simple div that fades in and
- 1:27
fades out when that button is clicked
- 1:29
every component has an animations
- 1:31
property which accepts an array first we
- 1:34
pass it a trigger which corresponds to
- 1:36
the name with the @ symbol in the HTML
- 1:39
then we define how each state should
- 1:41
look once the animation is complete when
- 1:43
that popover is being shown the opacity
- 1:45
is 1 when it's hidden the opacity of 0
- 1:48
to actually make this animate we need to
- 1:51
define a transition which sets the time
- 1:53
parameter for the animation to occur in
- 1:55
this case when we transition from show
- 1:58
to hide it will animate in 600
- 1:59
milliseconds and ease out and then when


