Jump to content
GreenSock

berikiushi

how to define a variable in the timeline?

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


var state = true;

var tl = new TimelineLite();

tl.to(element, 1, {width:"50%"})

.to(element, 1, {backgroundColor:"#FF0000"}, "-=0.5")

.set(state = false) //something like for example

.to(element, 1, {width:"50%", onComplete:state = false}); //or as

 

Link to comment
Share on other sites

have you tried this:

var state = true;
var tl = new TimelineLite();
tl.to(element, 1, {width:"50%"})
  .to(element, 1, {backgroundColor:"#FF0000"}, "-=0.5")
  // using the call method in the timeline
  .call(function(){ state = false }) //something like for example
  .to(element, 1, {width:"50%"}); //or as

using the call() method in the timeline : http://api.greensock.com/js/com/greensock/TimelineLite.html#call()

  • Like 2
Link to comment
Share on other sites

Thank you, did not think that need to wrap a function.

Link to comment
Share on other sites

  • 2 weeks later...

the documentation says that i can call at any time

tl.call(func, ["param1"], this, 2);  //appends it at exactly 2 seconds into the timeline (absolute position)

I try to do so and does not work:

.call(function(){ console.log('call.3'); }, 3)

help please.

Link to comment
Share on other sites

his own answer

.call(function(){ console.log('call.3'); }, [], this, 3)

thanx

Link to comment
Share on other sites

Yep, good job - you got it :)

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