Animated Like Elton John
This is the first chapter where our main focus isn't learning necessarily big topics, but instead mainly focused on improving our craft. We start off by creating an animation - a cluster of animations that are very specific- with defined names, defined times, defined delays and so forth. In other words, although our animations are quite impressive at this stage, they're not reusable. In the next few lessons, we're going to turn them into reusable elements.
Video Transcript
00:00Well, I'm still I don't think I'm allowed to continue because then there's royalties and stuff like that. So I
00:07Did that was my like I was fake Elton John this lesson is about
00:14Animations, so I thought I'd be a little bit more animated
00:17So let's get back to it and really this the next the whole chapter is really gonna be very deeply
00:23Ingrained into animation and in the process we're gonna be creating a
00:27user input
00:30We're gonna create an application based on users input. Welcome back chapter 6
00:35Where we're gonna be focusing now
00:36I've added into our HTML a few little properties here a few input boxes one where we'll put our name in
00:43The other where we'll put the name of the person that we're dating and then we'll click on the analyze button
00:48the idea behind this kind of
00:50Relationships connector is that we'll be able to see the connections and relationships between
00:55People we dated and how many people they dated before
00:58some that's the basic idea of it basically to create some sort of a webby kind of thing that you could put in all the
01:04Names of all the people you dated and what they dated and then we'll be able to see some sort of a relationship between them
01:10That is sexual and then the process will have a better deeper learning about
01:14Objects and learn about a few different types of objects that will help us through the path now before we even do that
01:20I want to go back to our animations
01:21And I really want to animate all these elements to kind of like animate in
01:26linearly from left to right
01:28So before we do that, I just want to show you what where we're starting at. So we're in our starting file
01:33I've updated the CSS file to chapter 6 where there's a few
01:37editions based on the new elements that we've added to the stage and we have your two spans span one span two our
01:44Name block contains two items a label and an input and the input is a text input for our name and same goes for our
01:51Date block where you have a label and a date input element the text input element last
02:16Last but not least we have an input for our actual button itself
02:20So the first thing that I want to do and if we look into our CSS
02:24We'll see that the new span elements that I've added
02:27Literally by default when we look into them, we'll see that there this is what we're going for
02:33This is gonna be our end goal
02:34We're gonna want to create this kind of like transition that is kind of smooth and and cool
02:39So how about we start with that? Let's start creating this process of creating this animation
02:44So if I go ahead just for a second and just save my HTML file that I'm in right now
02:49So we could see how it looks like just by default
02:52We'll see that by default everything is positioned where we want it to be
02:56Now we really want to undo that and set our beginning position of all our elements to be somewhere in this vicinity
03:02So to do that what I'm gonna do is I'm gonna go into my editor and then start off with the tween max set
03:11I'm gonna set the properties first of all those of spans
03:14So I'm gonna go there for slide span
03:17That would catch both my spans and the second item that I want is the ID of my submit button
03:22Which my submit buttons ID is BTN analyze
03:26So I got those two elements and now I can literally go ahead and basically set what I want them to be
03:32So first of all, I want to set their position
03:35To be absolute
03:38And that is because I want to animate the elements without a
03:41Relativeness I want them also to overlap each other
03:44So I don't want them to I want them basically to be able to be stacked on top of each other
03:49The next item that I want to modify is our position from the left
03:54left
03:55And I'm gonna why am I doing left and I want to position them at the zero pixels
04:00So if I go ahead and I save this and I just go into my app again
04:04Just to look at it for a second
04:05We'll see that now all my elements are gonna be now flushed on top of each other
04:10Last but not least I want to actually set them in the beginning to be with the opacity of zero
04:15So I'm gonna go ahead and add the opacity and set that to zero as well
04:20Alright, so now that we have our starting position where there's basically nothing visual in our elements
04:27All of our three elements are basically invisible
04:29then the first step is we want to first fade in our first property and
04:34Fade in the next property and then fade in the last property as we animate them into their position
04:40So let's start doing that so I'm gonna go ahead
04:42I'm gonna create a new tween max to because we want to do a to animation
04:47And I'm gonna approach each element individually because I want to create a different animation for each of them
04:52So we're gonna start with the name block
04:55which is the block with the name the span that has the name on it and
04:59I want to go ahead and animate that for one second and let's go ahead and tell what do we want to animate?
05:05So we want to animate the position itself. Well first of all, we want to animate its opacity
05:11Want to set that at one and we also want to animate the left position and we want to set it to oh actually
05:16We don't need to animate the left position because it's already in its spot
05:19So the first item we just want to animate and we don't need to change any other property besides animating it
05:24So let's go ahead and also continue and animate the the next property which is going to be our
05:30Date block and our date block we wanted to take one second
05:34Oh, so we want our opacity to be one as well
05:37But this time around we also want to move our move our left position
05:41And I'm gonna go ahead. I'm gonna set my left position to 220 pixels because I checked in advance
05:47how much gap we need and the next is I'm gonna add a delay because I want this to happen only a little bit after the
05:54First item starts. So I'm gonna go ahead and put here a zero four percent zero four second delay
06:01Now if we save this and just run it for a second just to see what's going on
06:04We'll see that our first element is coming in our second element is coming in at the same time
06:09What would be nice if we also push our copy here a little bit down and I'm gonna animate our copy down
06:14So I'm just gonna go ahead and back into my editor
06:17I'm gonna go ahead and do that as the first thing we do because we even want it to be a lot before
06:22We actually are done with the other animation
06:24So I'm gonna go ahead and I'm gonna select my book with slide class, which is of our paragraph
06:31I'm gonna give it a 0.5 second animation
06:34And I'm gonna go ahead and add another margin to our top
06:39Notice how I'm using a camel case and I'm not using a minus T and the answer is because minus is a reserved
06:46Character in JavaScript to use subs to subtract things so we would have set here
06:50We would put it with a camel case and I'm gonna go ahead and set the actual
06:55Margin from the top and the margin from the top that I want it to be is 35 pixels
06:59So if I save this now, we should see that the copy should now go my main copy should slide a little bit down as these
07:06Animations are continuing last but not least I need to add inside my analyze button and add that into the chain of animations
07:14so I'm gonna go ahead and I'm gonna animate it and its property was BTN analyze and
07:21We want it to take one second as well
07:25And we want our opacity to be one and we want our left to be I have that number saved on the side for me
07:33It's gonna be 430 pixels. That's where we want it to go
07:37And if I run this we should see that it's all gonna animate into its place
07:42I probably will want to do another small little tweak and
07:45By the way, this felt like way way too fast
07:48And the reason was we didn't put here any delay and the second thing is I really want to push this button a little bit
07:53Down, maybe two or three pixels down. So I'm gonna try to take care of those two should maybe even four pixels
07:58So I'm gonna go ahead and add a few more properties to this last animation
08:02I'm gonna go ahead and push our margin top for this one as well set it for 4px
08:09So it'll be four pixels pushed down and last but not least
08:13Let's not forget to add a delay because that did look weird
08:16I'm gonna add a delay of 0.8 seconds. And if I save this and run it, I should be happy with the outcome
08:26Beautiful. So that's it. We've created that step one
08:29We created our animation and by the way as we were doing this
08:31We were leveraging a lot of stuff that we've learned already when we're working with objects
08:35We're definitely working with functions because we're inside a fun and our function already
08:41We're working with objects and setting different types of objects creating them dynamically using that shorthand creation process
08:48And I don't remember if we talked about the delays already before but here you go
08:52We also learned about a property called delay which enables us to add delays to our animations now in the next lecture
08:59I want to continue where we left off here, but I want to make this code a little bit more smart now
09:05It's really nice that I know how many pixels my left is should be here
09:09But in reality in real applications, I really want to be able to create this in a way where I could use this
09:15More than just one time
09:17So the first step that I want to do is I want to get rid of hard-coded things and that's gonna be really the main
09:22Focus of the next few lectures
09:24so the first step is we're gonna focus on trying to turn this property that we're animating mainly the left property to be a
09:30Dynamic property that these numbers could automatically update based on information that we provide for it
09:36Making it a lot easier for us to add more properties later on or change what we're animating at a later stage
09:43So let's see that and we'll meet you in the next lecture where we continue exactly from that point
