Jump to content
Search Community

reverse() do not work inside a function

eccojava 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

Hi

I have not a lot of experience programming.

 

I try to do a small project to practice an to learn about GSAP.

 

I have a problem wen I try to reverse a Timeline, I Think is becase the function that execute the reverse() is inside an other function.

 

the problem appears when I click the first photo an then it move that photo an it reveal a text a 2 buttons; the black button on the left should reverse the timeline "exp1".

The line code where Is the reverse() in JS is line 74

Hope some one can help with this problem

See the Pen xeJNdW by gduque (@gduque) on CodePen

Link to comment
Share on other sites

The problem is you have a listener on the reverse button that will indeed reverse the timeline, but that button is inside the div with the listener to play the timeline. So when you click to reverse, the event bubbles up to the parent and instantly plays the timeline. You'll need to stopPropagation() to make this work. I stripped out all the extra timelines and unnecessary code in this fork:

 

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

 

more info about stopPropagation():

https://developer.mozilla.org/en-US/docs/Web/API/Event/stopPropagation

 

We appreciate demos with questions, but if you can simplify them to a bare minimum when you have a question, that would be great. Happy tweening.

  • Like 1
Link to comment
Share on other sites

3 hours ago, PointC said:

The problem is you have a listener on the reverse button that will indeed reverse the timeline, but that button is inside the div with the listener to play the timeline. So when you click to reverse, the event bubbles up to the parent and instantly plays the timeline. You'll need to stopPropagation() to make this work. I stripped out all the extra timelines and unnecessary code in this fork:

 

 

 

 

more info about stopPropagation():

https://developer.mozilla.org/en-US/docs/Web/API/Event/stopPropagation

 

We appreciate demos with questions, but if you can simplify them to a bare minimum when you have a question, that would be great. Happy tweening.

Thanks for your help, and sorry for the long code.

GRACIAS

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