Fireship · @fireship
Swipe, Tap, Pinch - HammerJS + Angular Animations
Uploaded December 29, 2017 · Length 9:14
Summary
how to add touch events and animations to angular progressive web apps using hammerjs and angular animations
- angular animations
- hammerjs
- touch events
- progressive web apps
- angular progressive web apps
- mobile animations
- angular mobile development
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
in case you haven't heard the good news
- 0:01
both Microsoft edge and WebKit Safari
- 0:03
are now supporting service workers in
- 0:05
their preview releases this is a huge
- 0:07
leap forward and sets up 2018 to be the
- 0:10
year of progressive web apps with that
- 0:12
being said what I want to show you today
- 0:13
is how to handle touch events that only
- 0:15
happen on mobile devices then use
- 0:17
angular to create animations in response
- 0:19
to these events as you can see here we
- 0:21
run a different animation on this
- 0:22
material card every time the user swipes
- 0:25
in a different direction if you're new
- 0:27
here make sure to subscribe and I
- 0:28
recommend that you follow along with the
- 0:29
source code at angular firebase comm and
- 0:32
while you're at it
- 0:33
I also recommend checking out Paul
- 0:34
Holidays YouTube channel and all the
- 0:36
awesome angular content he's creating
- 0:38
over there I'm going to kick this
- 0:40
episode off by building a brand new
- 0:41
angular app then we have a couple of
- 0:43
dependencies to add the first one being
- 0:45
hammer J S which is used to add support
- 0:48
for mobile touch events to your
- 0:49
progressive web app including rotate
- 0:51
pinch press pan tap and swipe then you
- 0:54
can install it in your app by running
- 0:55
NPM install hammer J s Flags save then
- 0:59
once installed we're going to go into
- 1:01
the main TS file and make sure to import
- 1:03
hammer J s there that'll make the events
- 1:05
globally available throughout your app
- 1:07
in this demo I'm using angular material
- 1:09
but that part is completely optional you
- 1:11
can follow the install instructions on
- 1:13
the official repo the important part is
- 1:15
that you install angular animations
- 1:17
which is included in the angular mono
- 1:19
repo so you can just install it with NPM
- 1:21
and then make sure to include it inside
- 1:24
of your app module so you should have
- 1:26
browser animations module inside of the
- 1:28
imports array we're going to be modeling
- 1:31
our animations after the animate CSS
- 1:33
library which is one of the most popular
- 1:35
libraries on github the library itself
- 1:38
is just a collection of CSS keyframe
- 1:41
animations so all we have to do is port
- 1:43
those over to angular so we can use it
- 1:45
with angular's browser animations module
- 1:47
we don't actually need to install this
- 1:49
package in our angular project instead
- 1:51
we're just going to copy and paste the
- 1:53
CSS keyframes over to the angular
- 1:55
animations keyframes the end result is
- 1:58
that we'll be able to trigger animations
- 1:59
natively in angular this will give us


