It's time to animate it all with CSS3 transitions
CSS3 introduced a powerful capability to animate without the use of JavaScript. In this quick lecture i'll show you how can we animate the new 3d Object we created throughout this section.
Keynotes:
- CSS3 Transitions
- JavaScript free.
- Very speedy as such.
Video Transcript
00:00After creating throughout this section,
00:022D and 3D transformations,
00:04it's time for us to animate them using native CSS3.
00:08We're gonna do that using CSS3 transitions.
00:12The three transitions are in the heart of this lecture
00:16and the wrapper of this section
00:18where we're not gonna use any JavaScript
00:20and not only that we're not using any JavaScript,
00:23it's actually gonna perform better than JavaScript
00:25because it's ingrained natively supported by the browser.
00:28So if we could lean on these type of animations,
00:31we're gonna cut down performance-related issues
00:34because CSS is a lot more efficient than JavaScript
00:37because it's a lot more set and defined
00:39and the browser could pre-configure much more easily
00:42those type of animations.
00:43So let's go ahead and see
00:44how to create CSS3 transitions.
00:49Well, before we could really wrap up
00:50this conversation about transformations,
00:52we met 2D transformations, now 3D transformations,
00:56we really need to know how to animate things.
00:58So I'm gonna show you the basics of it.
00:59It's actually really simple and really fun.
01:02So let's jump right into it.
01:02It's gonna be another really short lecture
01:04and it's gonna be a wrapper for this chapter section.
01:08So what I'm gonna do is I'm gonna go ahead here
01:10and create a hover state.
01:12To do that, I'm literally just gonna take my object
01:15and I'm just gonna duplicate the styling rules there
01:18and just define a hover state for it.
01:21What I'm gonna do is I'm gonna basically rotate my item
01:24whenever it's hovered.
01:25So literally what's gonna happen,
01:26we're gonna see the flip side
01:27whenever the item is hovered over.
01:29So if I go ahead here and click here on refresh,
01:31anytime we go on the item, we're gonna see the back face.
01:35But what I really wanna do is I don't want it to just jump
01:37because that would be silly,
01:38all the work we've done just for that.
01:40I'm gonna go ahead into our object itself
01:44and even before anything happens to it,
01:46I'm going to the transition.
01:48And what I'm doing here is transition.
01:53And I'm defining what is transitionable
01:56and how long does it take.
01:57So literally I could go item by item.
01:59In this case, we're really gonna be transitioning transforms.
02:04So a transform, we wanna transform to take one second.
02:06So I'm just gonna type there 1S for one second
02:09and that's not transition.
02:10Let me just type here transition.
02:14There we go.
02:15Then let's go ahead.
02:16That's all we really have to do to create a transition.
02:19Now anytime, and you could use this
02:20to not only 3D elements,
02:22you could do this really to any property,
02:23any CSS item that is visible item
02:26and go ahead and animate it.
02:27And in this case, if I go ahead here and click on refresh,
02:29every time I roll over,
02:31I'm gonna have a one second animation
02:32that will go from one side to the other
02:35until the next time that I'm rolled over the item.
02:38And that's it.
02:39Now you know how to create transformations and transitions,
02:42the basics of them and learn.
02:44You could learn a lot more if you check our references
02:46to learn more about other things
02:48you could do with transformations in general.
02:51So that's it.
02:52In the next lecture,
02:53which is gonna be in the next section,
02:55in the section that is all gonna be dedicated
02:57to a completely new topic,
02:59and that topic is SVG.
03:02So we'll see you in the next lecture
03:03as we start learning to draw and animate with SVG.
