Jump to content
GreenSock

shenning

return TweenMax.set() triggers immediately

Go to solution Solved by Diaco,

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

Hi everyone,

 

there is an issue when populating a timeline by the returned Tweens of a function. Using TweenMax.to() with a duration of 0 or using TweenMax.set() are triggered at function call:

function getTween() {
    return {
        one:TweenMax.set($el,{property:1}),
        two:TweenMax.to($el,0,{property:2}),
        three:TweenMax.to($el,1,{property:3})
    };
}

Property 1 and 2 are applied to $el on function call. Property 3 is applied as intended on TimelineMax.add(getTween().three)

Is there a way to prevent immediate trigger of Tweens with duration of 0?

 

Thank you in advance!

See the Pen bdKjzN by anon (@anon) on CodePen

Link to comment
Share on other sites

  • Solution

hi shenning :)

 

you need immediateRender:false , pls try this :

 

function getTween()
{
  return {
    one:TweenMax.set(el,{x:500,immediateRender:false}),
    two:TweenMax.to(el,0,{scale:0.7}),
    three:TweenMax.to(el,1,{rotation:45})
  };
}
  • Like 2
Link to comment
Share on other sites

Yep, Diaco is exactly right. To be clear, it is very intentional that zero-duration tweens run immediately - that's what most people expect because there's literally no duration to the "tween" (if you could even call it that), thus it should render right away. Otherwise, things wouldn't have changed/rendered by the time the next line of code is executed, but the developer may be expecting things to be done already and their code would break. That's why we created the immediateRender:false option :)

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