Elindo Posted September 2, 2021 Share Posted September 2, 2021 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 More sharing options...
Solution GreenSock Posted September 2, 2021 Solution Share Posted September 2, 2021 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 4 Link to comment Share on other sites More sharing options...
Elindo Posted September 2, 2021 Author Share Posted September 2, 2021 Yes, that works. Anyway... how you do to think like javascript? Link to comment Share on other sites More sharing options...
Shaun Gorneau Posted September 2, 2021 Share Posted September 2, 2021 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. 4 Link to comment Share on other sites More sharing options...
Cassie Posted September 2, 2021 Share Posted September 2, 2021 This is a really fun place to start - https://beginnerjavascript.com/ 6 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now