Learn Angular Animations with 5 Examples
Key Takeaways
This video teaches how to build animations with Angular 4.3+ using 5 key concepts
Full Transcript
animation is often the x-factor that separates remarkable apps from ordinary apps in this episode I'm going to cover five different concepts related to angular animations including a few new concepts that were introduced in angular 4.2 angular animations are built on the web animations API which is very similar to css3 animations if you're not comfortable with animation at all I recommend doing some practice with css3 first and then you'll be able to make the most out of angular's animation module the first step to get started is to import the browser animation module into whatever module you plan on using animations in this first example I'm going to create a fade-in fade-out animation that will show some content in a popover when a button is clicked we import the methods we need from the animation module and then we'll create a boolean variable show that will determine the visibility of the popover I also create a getter called state name which will return the boolean variable as a string either show or hide which we need when defining the animation itself in the HTML we use animations by prefixing the animation name with the @ symbol and then pass at the current state of whatever variable we're going to animate in this case the only possible values will be show or hide and then we add a button for the user to toggle this variable the end result should look something like this it's just a simple div that fades in and fades out when that button is clicked every component has an animations property which accepts an array first we pass it a trigger which corresponds to the name with the @ symbol in the HTML then we define how each state should look once the animation is complete when that popover is being shown the opacity is 1 when it's hidden the opacity of 0 to actually make this animate we need to define a transition which sets the time parameter for the animation to occur in this case when we transition from show to hide it will animate in 600 milliseconds and ease out and then when we transition from hide to show it will transition in a thousand milliseconds or one second with an ease in and the end result is that simple fade in/fade out animation now we're going to build an animation that can handle multiple different states here we have a photo gallery component and we're going to represent its state with the position variable then we'll add a few buttons for the user to change the state on the front-end then we'll apply the photo State trigger to the image itself the goal is to have the user click these buttons and have the animation go from state to state seamlessly so again we start by defining the trigger and then we have three different states that we need to define the move state will move the image across the screen we do this by using the transform and translate X which means translate on the x axis if you've used css3 animations this should look very familiar to you you can adjust the position using both a percentage or pixel value to enlarge the image we'll use the transform scale which will increase the size the image by a factor of 1.5 to spin the image we'll use the transform rotate and this takes degrees as arguments and operates on all three axes so now we have four possible States including the default state and that gives us 16 possible combinations to animate it'd be very cumbersome to define each transition individually but angular offers a wild-card option which we can use to apply the transition to every different possible state so here we apply the wild-card is a 500 millisecond ease back in the app we can now see that each of these 16 combinations will use the 500 millisecond transition what if you wanted to control the intermediate steps in an animation you can do this with keyframes first make sure you import the keyframe this method into your component then we'll use the keyframes as an argument to the animate method inside the transition keyframes represent points and time relative to the length of the animation itself so in this example we have a $2,000 second transition so an offset of 0.33 would represent approximately 660 milliseconds in this example we're just translating and rotating the image all over the screen just to demonstrate how keyframes can create nonlinear animations back in the app we can see the image moves to the right and then up before reaching its final resting state another cool feature about angular animations is the ability to run callbacks when an animation is either started or finished in this example we're just going to console.log the animation and its current state animation callbacks are really similar to button clicks or any other user of that we simply called a photo state dot start and then fire whatever function we want to fire then back in the type script we just create a function that will handle the console login for us this is especially useful if you want to run a sequence of animations in a very choreographed kind of way the last animation feature I want to talk about is lists animations which uses two features that are new and angular 4.2 the new query method allows you to select elements that are nested within an animation based on their HTML tag in this case we'll use it to query all the images nested within an animation context once we've queried those images we can use stagger to create a delay between each animation of each image creating a shutter like effect we start by defining the trigger and then the transition we'll just use the wild-card then we can query every image that is nested within that trigger and first we'll get the images and translate them off the screen then we add an animation within the context of stagger which will stagger each item in the collection by 600 milliseconds in most cases you would make the stagger delay a little bit faster but I'll keep it slow for this example in the template we have the animation trigger to it div passing the length of the collection to it and then we loop over a collection of photos because these images are nested within the photos animation the query selector will automatically grab all the images and put them into an array back in the app we see that each image slicing the screen one after the other that's it for angular animation basics if this video helped you please like and subscribe and if you want to support the channel consider becoming a pro member at angular firebase comm you'll get access to a free copy of my book as well as free one on one project consulting thanks for watching and I'll see you soon [Music]
Original Description
In this episode, I show you my top 5 concepts you should know when building animations with Angular 4.3+. Get the full lesson code: https://angularfirebase.com/lessons/animation-examples-in-angular-4-3/
Also, check out the official docs https://angular.io/guide/animations
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Fireship · Fireship · 31 of 60
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
▶
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Angular 4 Development and Production Environments with Firebase
Fireship
OAuth with Angular and Firebase Tutorial
Fireship
Anonymous Authentication with Angular and Firebase - Lazy Registration
Fireship
Angular Router Guards for Firebase Users
Fireship
Angular Firebase CRUD App with NoSQL Database Tutorial
Fireship
Upload Files from Angular to Firebase Storage
Fireship
How to Deploy an Angular App to Firebase Hosting
Fireship
Sharing Data between Components in Angular
Fireship
Loading Spinners for Asynchronous Firebase Data
Fireship
Angular 4 Transactional Email with Google Firebase Cloud Functions
Fireship
Firebase Database Rules Tutorial
Fireship
Autocomplete Search with Angular4 and Firebase
Fireship
Reddit Inspired Upvoting System with Angular and Firebase NoSQL
Fireship
Angular Drag-and-Drop File Uploads to Firebase Storage
Fireship
Text Translation with Firebase Cloud Functions onWrite and Angular 4
Fireship
Custom Usernames with Firebase Authentication
Fireship
Twitter-Inspired Follow Unfollow Feature with Firebase and Angular 4
Fireship
Simple Pagination with Firebase and Angular 4
Fireship
How to Connect Firebase Users to their Data - 3 Methods
Fireship
Add Toast Message Notifications to your Angular App
Fireship
Facebook-Inspired Reactions System with Angular and Firebase
Fireship
Learn NgModule in Angular with Examples
Fireship
Lazy Loading Components in Angular 4
Fireship
Stripe Checkout Payments with Angular and Firebase - Part 1
Fireship
Process Stripe Payments with Firebase Cloud Functions - Part 2
Fireship
Selling Digital Content in Angular with Stripe Payments - Part 3
Fireship
Angular 4 Full Text Search with Algolia - Part 1
Fireship
Algolia with Firebase Cloud Functions - Part 2
Fireship
Firebase Phone Authentication in Angular 4
Fireship
Top 7 RxJS Concepts for Angular Developers
Fireship
Learn Angular Animations with 5 Examples
Fireship
Advanced Firebase Data Filtering (Multi-Property)
Fireship
Realtime Maps with Mapbox + Firebase + Angular
Fireship
Angular Reactive Forms with Firebase Database Backend
Fireship
Send Push Notifications in Angular with Firebase Cloud Messaging
Fireship
Top 7 Ways to Debug Angular 4 Apps
Fireship
Infinite Scroll with Angular and Firebase
Fireship
Use TypeScript with Firebase Cloud Functions
Fireship
Realtime Graphs and Charts with Plotly and Firebase
Fireship
Role-Based User Permissions in Firebase
Fireship
User Presence System in Realtime - Online, Offline, Away
Fireship
Location-based Queries with GeoFire and Angular Google Maps
Fireship
Angular ngrx Redux Quick Start Tutorial
Fireship
Angular Ngrx Effects with Firebase Database
Fireship
Progressive Web Apps with Angular
Fireship
Angular Ngrx with Firebase Google OAuth User Authentication
Fireship
RxJS Quick Start with Practical Examples
Fireship
Send SMS Text Messages with Twilio and Firebase
Fireship
Firebase Database Performance Profiling
Fireship
Native Desktop Apps with Angular and Electron
Fireship
Subscription Payments with Stripe, Angular, and Firebase
Fireship
Firestore with AngularFire5 Quick Start Tutorial
Fireship
Angular HTTP Client Quick Start Tutorial
Fireship
Google Sign-In with Firestore Custom User Data
Fireship
Star Review System from Scratch with Firestore + Angular
Fireship
Angular Chatbot with Dialogflow (API.ai)
Fireship
Learn @ngrx/entity and Feature Modules
Fireship
Infinite Scroll Pagination with Firestore
Fireship
Faster Firestore via Data Aggregation
Fireship
Contentful - CMS for Angular Progressive Web Apps
Fireship
Related Reads
📰
📰
📰
📰
I Spent Two Years Maintaining a React SPA. HTMX Rebuilt It in a Week
Medium · Programming
The 5 Levels of Front End Engineering (And Where Most Developers Get Stuck)
Medium · Programming
Browser-Based PDF Editing with Vue 3 and pdf-lib
Dev.to · sunshey
Say Goodbye To Electron?
Medium · Programming
🎓
Tutor Explanation
DeepCamp AI