Jump to content
Search Community

Position parameters: Labels with offset

BKENNEDY test
Moderator Tag

Go to solution Solved by Carl,

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

Hoping this is an easy one for you guys... I just couldn't find an example or reference to pull from.

 

I understand the use of labels and offset timing. Also understand the use of adding an offset to subsequent labeled tweens. 

 

What I can't seem to figure out, is how to add an offset to the FIRST tween of a labeled sequence... in other words, using the code below, how to I add an offset of say, +=0.5 to the label of item2 so that items 3 and 4 fire at the same time?

 

tl.to(root.item1, 0.75, {x:100, ease: Expo.easeOut})
.to(root.item2, 0.75, {x:100, ease: Expo.easeOut}, "go")
.to(root.item3, 0.75, {x:100, ease: Expo.easeOut}, "go")
.to(root.item4, 0.75, {x:100, ease: Expo.easeOut}, "go");
 
I want to think it's something like this, but doesn't seem to work:
 
tl.to(root.item1, 0.75, {x:100, ease: Expo.easeOut})
.to(root.item2, 0.75, {x:100, ease: Expo.easeOut}, "go+=0.5")
.to(root.item3, 0.75, {x:100, ease: Expo.easeOut}, "go")
.to(root.item4, 0.75, {x:100, ease: Expo.easeOut}, "go");

 

I can work around it by hardcoding the offset on each tween, but I'm sure there's a more flexible way. Any help is appreciated!

 

Thanks

-BK

Link to comment
Share on other sites

  • Solution

Hi and welcome to the GreenSock forums,

 

If I understand correctly, the most common thing to do would be to add() your label first at the time you want it and then add all your tweens at that label

 

tl.to(root.item1, 0.75, {x:100, ease: Expo.easeOut})
.add("go", "+=0.5")
.to(root.item2, 0.75, {x:100, ease: Expo.easeOut}, "go")
.to(root.item3, 0.75, {x:100, ease: Expo.easeOut}, "go")
.to(root.item4, 0.75, {x:100, ease: Expo.easeOut}, "go");

or you can use add() to add an array of items including your tween and your label like

 

tl.to(root.item1, 0.75, {x:100, ease: Expo.easeOut})
//add tween and label 0.5 seconds later
tl.add( [TweenMax.to(root.item2, 0.75, {x:100, ease: Expo.easeOut}), "go"], "+=0.5")
.to(root.item3, 0.75, {x:100, ease: Expo.easeOut}, "go")
.to(root.item4, 0.75, {x:100, ease: Expo.easeOut}, "go");

I think the first method is more readable

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