Jump to content
Search Community

Play on click, when clicked while playing reverse. However, when finished call another function.

Terio test
Moderator Tag

Recommended Posts

Hello. I have started to learn JS few weeks ago and I found this amazing library yesterday. I decided I want to achieve a designed project with it. However, I've been reading resources on this website and reading forum posts, but after hours I still can fix it. Therefore I'm asking here for help.

 

The project is a bit complicated, but I'm hyped about it and that's the way I really want it to work. I think what explains it best is this graph I've prepared for this post:

 

bI0JLwV.png

 

I almost achieved this, but I have some problems. After finishing step 4, the animation is broken and reversed in an improper order.

 

Could anyone please try to help me fix my code? Please keep in mind I'm new to this. Thank you all in advance.

See the Pen eYVjwYQ by terramsc (@terramsc) on CodePen

Link to comment
Share on other sites

Welcome to the forums, @Terio

 

This seems like an odd way to set things up and I'm not sure I understand your goal correctly. You may not need 3 different state images that you animate the opacity of, although it's totally fine if you prefer to do it that way. Normally, you could just have one asset, like a <div> or SVG that you'd animate the backgroundColor or fill of, as well as the text color. There's no need to use multiple timelines or callbacks or anything like that. But again, maybe I'm just totally missing your goal here. 

 

Is this what you're looking for?

See the Pen GRQXqeO?editors=0010 by GreenSock (@GreenSock) on CodePen

  • Like 3
Link to comment
Share on other sites

That's it! Thank you so much. I'm annualizing that code and there are some new approaches there I didn't know about before. It's interesting, I will try to work with them in the future.

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