Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Elindo

Start button syntax.

Go to solution Solved by GreenSock,

Recommended Posts

What could be wrong with this syntax?

 

btnstart.onclick = () => {
  isButtonBDisabled = false;
  isButtonADisabled = false;
  if (animation == stagea1, stagea2, stageb1, stageb2){
    animation.isActive();
  }
  else animation = stagestart();
}

 

What I want to do is:

 

Enable buttons A and B <-- this is working

 

Check if A or B are playing any of their tweens, which are located in the functions or stagea1, stagea2, stageb1, and stageb2...  if any of these stages are playing, then I want the Start button to do nothing and just let them play.

 

If none of the stages are playing, then I want the Start button to play stagestart.

 

The .isActive I took it from gsap cheat sheet under control methods, but Codepen is telling me it can't read it.

 

 

See the Pen vYZLjJz by Elindo586 (@Elindo586) on CodePen

Link to comment
Share on other sites

  • Solution

Yeah, that's full of both syntax and logic problems :)

 

I assume maybe you meant to do this?: 

btnstart.onclick = () => {
  // if animation isn't defined yet or if that animation isn't active, do the stagestart() animation
  if (!animation || animation.isActive() === false){
    animation = stagestart();
  }
}

Again, please read the forum guidelines - we really try to keep these forums focused on GSAP-specific question rather than general JavaScript syntax, logic issues, build-to-order requests, etc. We love helping with GSAP questions though.

 

Good luck with the project, @Elindo

  • Like 4
Link to comment
Share on other sites

Yes, that works.

 

Anyway... how you do to think like javascript?

Link to comment
Share on other sites

13 minutes ago, Elindo said:

Yes, that works.

 

Anyway... how you do to think like javascript?

 

The best way is to learn the fundamentals and then start with small projects; projects with one goal. More complex projects are really many small projects that work in concert. You can sign up for e-classes or even learn from YouTube videos.

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