Jump to content
Search Community

variable value after animation

qqignatqq 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

How to specify the value of a variable after the end of the animation?
 

 var myvalue = 1,
     loadanimate = new TimelineMax();
     loadanimate.to('.logo', 2, {opacity:1, delay:0.2})
     .to('.layer-white',0.7, {x: "0%"})
     .to('.gotscroll', 0.15, { y: "-=10px", yoyo:true, repeat:5, delay:0.1});

I have this code. I need the variable "myvalue" to take the value "2" after the animation "loadanimate" is over.
1) How to do this?
2) How to make myvalue take the value "2" after the animation of ".layer-white" is over?

Link to comment
Share on other sites

Sorry about the delay - it looks like you posted in the wrong forum (the Flash/ActionScript version which hasn't been actively supported for a while). I'll move the topic over to the appropriate place.

 

It looks like your code indicates you're using the more modern JavaScript/HTML5 version. Great. 

 

There are actually many ways you could accomplish this. It's probably simplest to use an onComplete callback, like:

 

...
loadanimate.to('.logo', 2, {
  opacity:1, 
  delay:0.2, 
  onComplete:function() {
    myvalue = 2; //<-- there ya go
  }
})
...

 

You could put the onComplete on the TimelineMax() instance if you'd prefer to have it run after the entire timeline animation is done. 

...
loadanimate = new TimelineMax({
  onComplete:function() {
    myvalue = 2;
  }
})
...

 

Does that help? 

  • Like 2
Link to comment
Share on other sites

GreenSock Jack! Да!!! Это решает мою проблему! Огромное вам спасибо!!! Из России с любовью!

 

 

I'm sorry that I placed it in the wrong branch, I got confused...

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