Jump to content
Search Community

is set() the same as startAt ?

Lefthandmedia 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

Not sure how you ended up there, usually you wouldn't want to do that. And no, it is quite different. Instead you will want to use fromTo tween or combination of using 'set' and 'to' tween. Generally you will want to use fromTo tween to keep things more organized.

 

If you are not familiar with immediateRender, when you use set method or define from or fromTo tween, GSAP will set your element to the starting position as soon as that statement is executed. In some cases you want to avoid that so you will set immediateRender to false.

 

Contrary to from, fromTo and set. To tweens animate from their current position to a certain position so they dont have immediateRender. So if you have any kind of delay on the tween your animation will jump when tween will start.

 

Take a look at following demo and video to learn more about different tweens and how immediateRender affects your animation.

 

See the Pen pZeYPb?editors=0110 by Sahil89 (@Sahil89) on CodePen

 

 

  • Like 3
Link to comment
Share on other sites

 

 

startAt is a legacy property that is really only useful if you want a to() tween to behave as a from() tween as it allows you to specify at which values you should startAt (from).

 

As Sahil mentioned. using set() and then a to() or just a fromTo() is going handle pretty much any situation you need. I don't think startAt is really necessary for anything these days.

 

Definitely check out fromTo: https://greensock.com/docs/TweenLite/static.fromTo()

 

I wasn't entirely sure though what you were asking as neither of the code snippets you posted are valid.

to() tweens need a duration
 

bad

TweenMax.to(obj, {x:1000});

TweenMax.to(obj, {x:1000,startAt:{x:100}});

 

proper

TweenMax.to(obj, 0, {x:1000});

TweenMax.to(obj, 0, {x:1000,startAt:{x:100}});

 

A set() is just a tween with no duration.

The following 2 lines do the same thing

TweenMax.to(obj, 0, {x:1000});

TweenMax.set(obj, {x:1000});

 

If there's something specific that you can't do with set() or fromTo() or something you need startAt for that isn't working, please provide a basic demo and explanation.

 

 

We'll be happy to try to clear things up.

 

 

 

 

 

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