Jump to content


Set default value for rotation, opacity, etc.

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

Is there a way to set a default value for the rotation of an element, before starting to animate it with the timeline?


For example:


When loading the document, set element to rotation 180, and opacity 0. Then start timeline with rotation to 0 and opacity to 1. Delay for 2 seconds. Fade out all elements. Start over again.

Link to comment
Share on other sites



Sure you can use a TweenLite.set() or TweenMax.set() instance.


They are an abbreviated way of using a zero duration tween and the greatest thing is that you can also use them in timelines using the shorthand method set, like this:

//individual instances
TweenLite.set(element, {rotation:180, opacity:0});
TweenMax.set(element, {rotation:180, opacity:0});

//In a timeline
var tl = new TimelineMax();

    .set(element, {rotation:180, opacity:0})
    .to(element, time, {rotation:0, opacity:1})
    .to(element, time, {opacity:0});

Although in the scenario you describe it'll be better a from instance, that can also be used with the shorthand method in a timeline:

var tl = new TimelineMax();

    .from(element, time, {rotation:180, opacity:0})
    .to(element, time, {opacity:0});

This codes will produce the same results.




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.