Jump to content
Search Community

immediateRender doesn't work with nested timelines

sebHewelt 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

 

So I have two timelines:

- masterTl 

- subTl (within masterTl)

 

What i want to achieve:

I would like my canvas element to be hidden, and set to visible on start of the animation.

 

What i get:

When I set visibility in CSS to hidden, and set it back to visible at the beginning of the timeline...:

 

CSS:

canvas {
  visibility: hidden;
}

JS:

subTl
.set(canvas, {
visibility: 'visible'
})
masterTl.add(subTl);

 

...it immediately sets visibility: 'visible', when the subTl has no {paused: true} set. If I set {paused: true} on subTl it works, but stays paused (therefore does not set visibility to visible) on masterTl.play(), (which is obvious). I don't know how to get around it.

I tried to set  {immediateRender: false} in both timelines - no luck.

 

Examples:

Here are two examples, one with subTl {paused: true}, and the other one without that setting:

 

Pen with {paused: true}

See the Pen WZaOOQ by RycerzPegaza (@RycerzPegaza) on CodePen

 

Pen without {paused: true}

See the Pen pWxwPE?editors=0010 by RycerzPegaza (@RycerzPegaza) on CodePen

 

Help desperately needed :)

 

 

Link to comment
Share on other sites

Hi @sebHewelt :)

 

A couple things and you'll be good to go. You're using 'initialRender:false' in your pen when you should be using 'immediateRender:false'.  That immediateRender property should be on the tween, rather than the timeline. So you have a couple options to get things working. You can write your set() like this:

subTl.set(canvas, {visibility: 'visible', immediateRender:false});

 

 You can also create your nested timeline in a paused state and then add it to the master like this:

masterTl.add( subTl.play() );

 

Either way should get you to your goal. Hopefully that helps. Happy tweening.

:)

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