Jump to content
Search Community

TweenMax.to OR TweenMax.set

jeff2019
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

Posted

Hello,

 

I am discovering GSAP and I did an exercice with TweenMax,

 

And I don't understand why I have to write :

 

TweenMax.set('....', {transformPerspective: xxx});

 

If I write the same thing with TweenMax.to and it don't works ...

 

Can someone tell me when we have to use the 1st one and the 2nd one ?

 

 

ZachSaucier
Posted

Hey Jeff and welcome to the forums! 

 

The .set method is essentially a .to but with a duration of 0. But it's used to set properties of an element without an animation. It makes sense to use it for a transformPerspective because you don't (usually) want to animate that property. 

 

However, it should work for you if you do TweenMax.to('.foo', 0, {transformPerspective: xxx}); I'm guessing you just forgot the animation duration in the .to call (the second parameter). 

 

Does that help?

 

For more information, check out their docs pages: TweenMax.set and TweenMax.to.

Posted

Without a codepen demo to see the context, it'd difficult to know for sure but typically it's best to just set a perspective on the parent element rather than a transformPerspective on the element itself. I assume you're doing some 3D-related transforms? 

  • Like 2
Posted

Hi, 

 

Thank you all for your answers it helps me to understand :)

 

Yep I wrote

 

TweenMax.set('#box',{transformPerspective:600});
TweenMax.to('#box',4,{rotationY:360});

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