02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School
Previous VideoNext Video

Setting properties

Just like TweenLite/TweenMax enabled us to change properties without animating the change, so does TimelineLite. In this lesson, we will discover the TimelineLite.set method.

Video Transcript

00:00And we continue traveling through methods that are very similar to the methods we met in the tween light in tween max
00:08And this time around our main focus is going to be the set which basically as we saw in the past enable us to set
00:15Properties, but we could also use it to set things as we're going through a timeline saying at this point in the timeline
00:21I want to set something so let's get ahead and do that for us to fix that problem of
00:27Jumpiness that we have now the way we're going to solve this very very very very familiar to you
00:33It should be because if you have
00:36Taken any of our courses before you already know that the tween light and the tween max have the property that's called set
00:42and so does our
00:45timeline and
00:46To be able to do that what I want to do is first of all my problem is I have to set your
00:50Initial value I could very easily just set it to be the initial clip value to be basically nothing
00:56To make sure that I have basically a clean slate when I start that isn't a very reasonable beginning because when I start my animation
01:04It's gonna start and it works really well for me. That's only because I'm starting from an invisible position
01:10But what if I wasn't but let's see first of all if I did this and I set it from an invisible position
01:14It should be basically fine
01:16What if in contrary to that I wanted it to start from the position of the last item for example
01:23And if I wanted it to start from the position of the last item. Let's go ahead and do that
01:27Let's go ahead and do that. I'm gonna
01:29Undo this clipping zero here for a second
01:33Although that would probably work even if we did that when I think about it now
01:37What I'm gonna do is I basically I'm just gonna take that
01:40Value of our left and our right and I'll just subtract the slice width from both of them
01:45So literally what I'm gonna do is I'm just basically gonna take this value that we have here
01:50Although it's not gonna work for the first item, so I'm trying to think out loud. All right, let me do it anyways
01:56I'm just gonna copy this value and paste it in again
02:00So we're basically animating from the same spot to the same spot and what I'm gonna do to the right itself
02:05Let me just surround it with a bracket
02:07I'm gonna subtract from the right the actual slice with
02:11Basically giving me a value that should be on the first item only a negative which we probably should fix that by basically setting your
02:20Math dot max and I'll just set your zero or that value and I'm gonna do the exact same thing
02:26Oh, so for the left position, so I'm just gonna copy this
02:29And I'm just gonna swap the left position and make sure making sure that I'm gonna use the word left here
02:35And literally what I'm doing here is I'm basically getting the value of the last item and putting it instead
02:41But here the minimum value wouldn't be zero for the left
02:43The minimum value probably should be that geek to slice with so the minimum size
02:48We could have is the actual width itself
02:50This way I'm making sure that I could never have a minus for my right side, but nor could I have for my left side?
02:57Let me see if that would be it. Oh, no, actually for the left side
03:00That would be zero for the right side
03:02We want it to be a minimum not of zero but a minimum of the slice with itself that way we're making sure
03:08That we have at least the size of a width between the two of them
03:11So if I go ahead and just save this and refresh it
03:14We're gonna get a completely different animation going on and if we click here on refresh
03:19First of all, we could see that these animations are taking place and they're going in place
03:22But obviously our problem right now is that we don't want these initial positions at all
03:27We don't want them to be there now again if we wanted to we could have had that initial clipping of nothingness
03:33And then set that clipping back and basically have it basically just start whenever it starts
03:38All right, that's that's an option
03:40But another a better option than that would probably be to have the item may be faded out in the beginning opacity
03:47Set the opacity to zero and then I could if I want to just set the in my from
03:53Element here just go ahead and add the property of opacity again and set it to one
03:58Basically making sure that I'm gonna start from one so it's gonna just turn on at that point
04:02So if I save that go back and click on refresh, then only when my animation is actually starting
04:08Then it's actually gonna suddenly be be there now beyond that
04:12I want to show you just another another example another something that we could do is if I don't set the opacity here
04:18I could also set it first of all one more option just before we wrap this one and we show the set itself is
04:23I could have if I wanted to oopsie
04:25I could have if I wanted to just set the opacity on to on the on the second parameter of the
04:31Basically the two parameter and have it basically fade in as it's coming in
04:35And if I if I would have it fading it as it's coming in
04:37we would have a very interesting effect a much more interesting effect really because then we're making sure that it's not visible until we
04:44Actually want it to be visible
04:47Because what we had before when we were setting the from to we had elements that are
04:52Staggering they're sitting there waiting for something to happen to them, which wasn't really working for us too
04:56Well now another option that we could do which was a really nice one as well
05:01As we could literally go ahead into our geek to
05:05Timeline oops, what am I doing here?
05:09Timeline and I could go and set a parameter to this
05:13Because it's set doesn't have seconds
05:15I could literally just say what I want to do and what I want to do is I want to set opacity of one
05:20When do I want this to happen?
05:21I want it to happen basically in parallel when this animation is starting and because this is not going to change my playhead because there
05:28Is no time on it. It's going to automatically go to the end of my playhead
05:31I could literally just match up between the two saying a turn the opacity on when you're starting this animation and by doing this
05:39If we take a peek at it one more time
05:40We should have a much cleaner animation where our item is only snapping and becoming visible when it's time to become visible
05:49Obviously, this is not a pretty animation
05:51But it's an animation that helps you see the different structures of how could you define these type of stuff personally?
05:56I prefer the fade and more than anything else
05:58But I wanted to use the set because you might have a scenario such as maybe when this whole thing is complete
06:04Maybe you want to have something happen for example
06:07Which is you know, let's do that in the next lesson
06:10What do what if we want to call a function in between these items or I wanted to call a function when everything here?
06:16When when the last animation is complete in this stage?
06:20How do I do that or what if I wanted to call it in between every single animation?
06:24That's a viable scenario. So let's see how we do that in the next lesson
06:28you

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!