Jump to content
Search Community

Multiples targets with multiple values

jniac 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

This had to be discussed but i can't find a topic about it.

 

Is there a way to do something like :

var obj1 = { myValue:random };
var obj2 = { myValue:random };
...
TweenMax.to([obj1, obj2, ...], d, { myValue:[value1, value2, ...] });

when at the end :

obj1.myValue // value1
obj2.myValue // value2
...

?

Link to comment
Share on other sites

Of course a for loop do the job...

var objs = [...];
var values = [...];
for (var i = 0; i < objs.length; i++)
    TweenMax.to(objs[i], d, { myValue:values[i] });

But we have to declare two arrays first, a single line would be more elegant!

Link to comment
Share on other sites

Eh? What? Not sure what the question is.

 

But, if you want to cycle thru several values in several elements, the cycle method is your friend. ;)

 

Check out the link but here's the basic usage using your example as a basis:

TweenMax.staggerTo([obj1, obj2, ...], d, { cycle:{myValue:[value1, value2, ...]} });

If you omit the stagger amount, it will behave as a simple .to() tween, by the way.

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