Jump to content
Search Community

Set visibility at start of timeline

jnhltmn test
Moderator Tag

Recommended Posts

I set the visibility of my elements on 'hidden' with css and on the start of my GSAP 3 timeline I want to set the visibility at visible.

It works in a single tween, but when it's part of a timeline it doesn't. What's wrong with my code below?

 

var tl = gsap.timeline();
tl.set(".class", {visibility:"visible"});

See the Pen dyygPob by jnhltmn (@jnhltmn) on CodePen

Link to comment
Share on other sites

Hey jnhltmn,

 

Interesting edge case. If you add a tween after the .set() call it will work as you expect it to. But since there's no tween, the timeline has a duration of 0 and therefore doesn't even play. @GreenSock would you consider this a bug? It's an extremely rare circumstance since most people would just use a gsap.set(), not a timeline.set() if there's not other tweens...

 

Also @jnhltmn, if you're tweening from visibility: hidden know that you can just tween autoAlpha instead of opacity and it will automatically set the visibility to visible for you.

  • Like 1
Link to comment
Share on other sites

Thanks a lot Zach! I wanted to add more tweens after making the elements visible, so I got stuck at the first tween of my timeline! :D 

And yes, I was aware of using autoAlpha instead, but I tried to understand what was wrong with my code in the first place. Thanks for clearing that out!

  • Like 2
Link to comment
Share on other sites

I'm so sorry - the email notification for this thread wound up in my junk mail filter and I'm just seeing it now. 

 

Yes, I'd consider this a bug - it should be fixed in the next release which you can preview at https://s3-us-west-2.amazonaws.com/s.cdpn.io/16327/gsap-latest-beta.min.js

 

Thanks for reporting it. Sorry about the confusion that caused. 

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