Jump to content
Search Community

Set boolean value in tween / timeline

stot test
Moderator Tag

Go to solution Solved by Shaun Gorneau,

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 Guys,


I try to set a boolean value in the TimelineMax.set() method, like this:

tl.set(toAnimate, {
        y: 50,
        visible:"true",       // also tried visible:true
        alpha: 1

But this gives me a NaN value of the visible property of my toAnimate object. But neither visible:"true" nor visible:true are working.


The solution using a callback seems for me a bit over sized (see here http://greensock.com/forums/topic/2456-tweening-boolean-value/)


Is this the only solution?



Link to comment
Share on other sites

Yup, Shaun is correct, TweenLite will not tween String values. 

Another idea is to use 0 and 1 instead of false and true.


Since this is part of a timeline you can either put an onStart callback on your set() or use a separate call() to run a function that will modify toAnimate.visible. 


EDIT: after reading GreenSock's post below, I just want to clarify that I was assuming that toAnimate was a generic JS object and not a DOM element like:


var toAnimate = {y:20, visible:"true, ...};

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