Jump to content
Search Community

Valid Labels

multivac test
Moderator Tag

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

Hello @multivac and welcome to the GreenSock forum!

 

The label names are created by you, so you can use any name you want, so they will be valid.

 

Now as far as the use of labels in a tween, read below:

 

The parameter that labels go into are called the position parameter.. see here for more info:

 

.to( target, duration, vars, position )

 

https://greensock.com/position-parameter

  • position: *
    (default = +=0) — Controls the placement of the tween in the timeline (by default, it’s the end of the timeline, like “+=0”). Use a number to indicate an absolute time in terms of seconds (or frames for frames-based timelines), or you can use a string with a “+=” or “-=” prefix to offset the insertion point relative to the END of the timeline. For example, "+=2" would place the tween 2 seconds after the end, leaving a 2-second gap. "-=2" would create a 2-second overlap. You may also use a label like "myLabel" to have the tween inserted exactly at the label or combine a label and a relative offset like "myLabel+=2" to insert the tween 2 seconds after “myLabel” or "myLabel-=3" to insert it 3 seconds before “myLabel”. If you define a label that doesn’t exist yet, it will automatically be added to the end of the timeline before inserting the tween there which can be quite convenient. Be sure to read our tutorial Understanding the Position Parameter which includes interactive timeline visualizations and a video.

 

Happy Tweening! :)

 

  • Like 6
Link to comment
Share on other sites

In addition to Jonathan's advice, you can use TimelineLite's getLabelTime() method. If the label isn't found it returns -1

https://greensock.com/docs/TimelineMax/getLabelTime()

 

 

To get an array of labels in a TimelineMax you can use the getLabelsArray() method: https://greensock.com/docs/TimelineMax/getLabelsArray() which returns an array of label objects which look like {name:"labelName", time:4}

 

You can loop through that array and search for a match but getLabelTime() should do what you need.

 

 

 

 

  • Like 6
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...