Jump to content
GreenSock

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

Can I specify the element variable?

Recommended Posts

Hello. Can I gather animation and then substitute a variable? In the Codepen example, if the field is empty, "No" appears, but if the field is filled in, "Yes" should appear. How do I do this?

 

See the Pen YMvbeo by anon (@anon) on CodePen

Link to comment
Share on other sites

It will probably be easiest to create a new tween/timeline after you click.

 

See the Pen ROJzXj by PointC (@PointC) on CodePen

 

Hopefully that helps. Happy tweening.

  • Like 1
Link to comment
Share on other sites

Thank you. Can you make the start up through restart? The user can't wait for the animation to finish.

Link to comment
Share on other sites

Hi qqignatqq,

 

Can you elaborate on your question, I am not sure I understood.

Link to comment
Share on other sites

You can't restart a timeline with a new target. That's why I suggested creating a tween/timeline in your click handler. You may want to make two timelines and play the appropriate one. You could also clear the main timeline on each click and repopulate it with new tweens upon click. You can check if it's active and quickly set the progress() to 1 before clearing so you don't get weird jumps. There are lots of possibilities. I don't really understand what you're doing so it's hard to give the best advice.

  • Like 1
Link to comment
Share on other sites

That's what I'm looking for. This is the form of sending the letter to the post office and I need the result of sending. The user can click on the "Send message" button several times and I need the animation to work every time. How can I reset the animation and restart it? I tried to put "clear()" in different places, but I failed.

If the form is valid and the "NO" animation is not finished yet, it should end and the "YES" message should appear

 

I'm sorry if I'm not clear, I'm using a translator.

 

Link to comment
Share on other sites

I'd probably just check if a timeline isActive and set the progress to 1. Then create the appropriate new timeline. Maybe like this:

 

See the Pen wZxRbb by PointC (@PointC) on CodePen

 

Happy tweening.

 

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