Jump to content
Search Community

TimelineMax.add("label") method

venn test
Moderator Tag

Go to solution Solved by GreenSock,

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hi all,

 

I am trying to understand this 2 pieces of code. 

 

A )

tl.add("Greenlawn Point")
.to($map, 0.5, {x:-155, y:-80}, "Oceanside")
.to($map, 0.5, {x:-656, y:-270}, "Pineapple Island")
.to($map, 0.5, {x:-926, y:-560}, "Oasis Villa")
 
B )
tl.add("Greenlawn Point")
  .to($map, 0.5, {x:-155, y:-80})
  .add("Oceanside")
  .to($map, 0.5, {x:-656, y:-270})
  .add("Pineapple Island")
  .to($map, 0.5, {x:-926, y:-560})
  .add("Oasis Villa");
 
The result produced are different but I thought I have added the labels the same way on both A and B?
 
Cheers, Venn.
Link to comment
Share on other sites

  • Solution

Almost, but not quite. When you define the insertion point as a label that DOESN'T EXIST, it will automatically add it to the end of the timeline and then put the tween starting there

 

In A), you add "Greenlawn Point" at the very beginning, and then you add a tween at "Oceanside" but since "Oceanside" doesn't exist yet, it adds it to the end of the timeline which at that point is ZERO (the timeline is empty) and adds the tween starting there. So in A), you've got "Greenlawn Point" and "Oceanside" at exactly the same place...the beginning. 

 

It looks like you assumed that it would add the tween first and then slap the label on AFTER the tween (but that's not the case). It puts the label in first because it's more intuitive. Otherwise, when you seek("Oceanside"), it would jump to the spot AFTER that tween whereas most people would associate that label with the tween itself, thus it should jump to the spot where the tween starts. 

 

Does that clear things up? 

  • Like 3
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...