The constructor data object
The timelines (TimelineLite/TimelineMax) have a built in functionality that is similar to the ones found in the tweens (TweenLite/TweenMax). In this lesson, we will connect the dots by taking a look at the data object properties.
Video Transcript
00:00Exactly like the tween light and tween max and have that construct has that constructor object so do timeline
00:07Light and max
00:09Objects have that we could send in startup
00:11Elements most of the stuff there are exactly the same like tween light and tween max
00:15So we don't we're not going to really go through every single one of them
00:18But with that said we are going to go through a couple of properties that really match up to all the stuff
00:23We were doing in this lesson
00:24And that is in a scenario where we already have pre-configured a few animations
00:28And we want to send them in send them into our constructor and give them a few rules of how to work with them
00:34It's gonna be really easy this lesson. So let's jump right into it
00:36See how we could do that end of this chapter, but before we even approach fixing all the animations
00:42I want to redo this initial animation and
00:46do it with tweens because I want to show you one more way of doing things because you definitely could be in a scenario where
00:52You have already tweens and you want to push them into the constructor of your timeline
00:57So let's see how that would work
00:59basically, what I'm gonna do is I'm gonna go ahead here even before I construct my
01:03Object my timeline and we've seen already that the the timeline accepts a parameter here that such as callbacks and different parameters that we've explored
01:11already previously and
01:13A lot of properties are just the same as in tween light and tween max
01:17So the ones that are the same we're just not going to talk about those are things that I feel like you could figure
01:21Out on your own because we already talked about those things quite deeply
01:25Alright, so what I'm gonna do is I'm just going to focus on things that are very specific to the timeline and things that are
01:31Specifically it. Alright, so let's get started. First of all, I want to get basically this array of spans after it's created
01:39So I'm gonna go ahead here and just literally I'm just gonna take this timeline
01:42I'm gonna delete it and move it because I really want to do this after I have this everything here configured
01:49Okay, so we have everything configured
01:51I'm creating the timeline and even before I create the timeline what I want to do is I want to grab that span of items
01:57And I'm just gonna call this
02:01just a variable here VAR
02:06VAR and I'll set the variable name to a spans
02:10And I'll just set the value in there
02:13The next thing is I want to get also the length of it because I want to basically loop through it
02:17So I'm gonna go ahead here and loop
02:20Through it's asking for its length
02:24Gonna ask my a spans length and I'll create a quick loop
02:29obviously in this type of scenario would probably be way more efficient for us to just use the
02:35Way we've done it before with the stagger from if we wanted to create some sort of a stagger effect or even if we just wanted
02:40To add things it would probably be easier to just use the ad
02:42But I want you to be aware of it because you could definitely be in a scenario where you just need it
02:48Now the next thing that I'm gonna do is I'm gonna create your O2 an array
02:51but this time around this array is gonna contain all of our tweens, so I'm gonna call this a tweens and
02:57I'm just gonna set the value here initially to be
03:00empty array and I'm just gonna go ahead and
03:04literally just go one by one and add into my a tweens just push into it a new tween a
03:11New tween light and the properties of the tween light. Oh, we don't even need new right? So I'm gonna do a tween light
03:18To and
03:19I'm just gonna let or actually from in our case because we want to create the same effect
03:24So I want to go here and I'm gonna go to the item a spans
03:27I'm literally copying this animation only with the right parameters this time around going through from the first item
03:35Which is in position?
03:36I then the second parameter is how long we wanted to take and the last parameter is our animation itself
03:42Which is right here
03:44So here we go we created those all these spans and if I just comment this out for a second and just save it
03:51Then this should work only it's gonna be not in conjunct conjunction with our timeline
03:57So if I click on save here, it should run separately from our timeline
04:00We'll still have a three-second delay, but that's all of the delay that we're gonna have
04:04So I'm gonna click here refresh for one two three and in the third second
04:09It should start animating in unless we have here an error which we do as always
04:13So missing a parameter in line 23. So let's see line 23
04:18What's missing here? We're probably our application is probably close when we close the parameter
04:24It you know
04:26that's what I hate about these
04:27Smart editors that are smarter than I am that they decide for me that they're gonna remove my brackets
04:33How dare they all right so back in there. Let's click on refresh and hopefully now
04:37We're not gonna have an error
04:39So one is this is working with a top item wasn't really animating. Let's see why it's not animating. So we have here the from
04:46That seems about right. So maybe we're not just in it. And let me just I'm gonna comment this out
04:51You know
04:52I don't really care about all the rest really because all I care about right now is getting this initial animation to to follow through
04:58And we really don't want to call this
05:01On images done on the images done thing until we're done really
05:05So if I just save this for a second just the way it is go back refresh it
05:09Let me just make sure that for var I equals 0 that could have been my mistake
05:14Go back in there click on refresh
05:18So yeah, it's working you can see that they're all animating in at the exact same time, right?
05:22That's exactly what we'd expect it to do good
05:25So now that we have our item and it's actually animating in the next step is to actually create our constructor
05:31And we're creating our constructor. I could literally send all those tweens that I've created
05:36Using a property that's called tweens
05:39So I just type your tweens and I could literally just send in our a tweens now by sending it in now
05:45It's going to be part of the timeline and now that it's part of the timeline
05:48I could go ahead and use that call and that call won't happen until after all those animations
05:53So it will happen only in second for right now
05:56So I go ahead here and click on refresh then we should see that fade in and a second after that is done
06:01Then that call will happen which would basically replace our hit h1 back to its original
06:09Unseparated state so after those three seconds, you'll have a one-second delay and then it's gonna refill its positions. Perfect. So we're getting closer
06:17The next step because we don't need the stagger anymore
06:20We could definitely load in the images, but we want to create a stagger. So to create a stagger
06:25I'm gonna first of all go to the stagger property and
06:35Set the value of the stagger property to be that zero dot two like we had previously
06:40And just by setting that I should have that same stagger effect that we've had earlier
06:45Having that animation that we want really wanted to have really beautiful animation that we wanted to have
06:51Now beyond that stagger that we created we could also affect one more thing the thing that we affected when we were doing the ad
06:59A really long time ago, which is the align property and we're not going to go into the difference
07:05Item the different options of the line, but I'm gonna do here basically
07:11Sequence align just to show you that I could have basically a seek
07:16wins and
07:17If I set my aligned sequence and it has also a stagger effect
07:21It's gonna cross reference with each other because the default was the normal and a reminder the normal means that it's gonna
07:28Align to the start time of all the tweens, which means all the tweens would start at the at the same time, but
07:35It would honor delays if there were any delays start
07:38We said would start them all at the same time ignoring delays and we said sequence will have each item go one after each other
07:45So not only will each item go after each other
07:47They'll also have another extra stagger of a zero dot two seconds
07:51So literally will have your an item fading in a weight item fading in a slight weight and so on and so on
07:58and so on
08:00So that's that's the that that those are these properties a three priority could configure and play with this only takes effect to that first
08:08Animation, it doesn't influence anything else
08:10So once this is done, I could without any problem load my images
08:14Whatever rules I had to them will still apply the starter rules that we have here for the tween stagger align
08:21Are only applicable to these initial tweens that we push into our constructor
08:25So if we don't have an initial tweens, we won't ever put your stagger aligned because they're not relevant
08:30They're only relevant if there is a tweens array that is being sent into our object
08:34So that's it. If I save this run it one last more time. We should have both our images
08:40Joining along after a few seconds. Oh, this is way too slow. So let me change this align to be normal
08:46Which is the default and we'll refresh it again
08:51So we don't have to wait forever for the animations to take place
08:56And there you go. We have our fade completing. We'll have a slight delay of three seconds
09:02Then the copy here will reset as the animations here are going through. So there you go
09:08Congratulations. We just built a much cleaner animation
09:11We're almost done with this course with this chapter really not this course
09:14And I'm just gonna have one more video to try to figure out a nicer cleaner animation for this last stagger element
09:20And I'm gonna also get rid of this wait time because I don't want to really wait what I'm gonna do is I'm gonna
09:26Add here minus three because I want it to happen almost in parallel
09:30So if we go here and click on refresh with this minus three, then it should start the images just start animating at some point
09:37Before all the rest is done or very close to it. In any case
09:42The next thing we're gonna do is try to find out a cleaner animation and with that
09:46We're gonna wrap up this chapter and move on to more advanced
09:51features of the
09:53timeline
