Jump to content
Search Community

Timeline reverse

lauraddr test
Moderator Tag

Recommended Posts

Hey Laura and welcome to the GreenSock forums!

 

A few notes about your code:

  • I cleaned up your markup and CSS to only what you need. I highly recommend using classes that are shared between elements to apply the same styles to different elements.
  • You don't need to wait for the window's load event since the JS is added at the bottom of the <body>.
  • You're using the old GSAP syntax - I recommend learning the GSAP 3 syntax that's sleeker. 
  • I'd use GSAP's defaults to save you some typing.

 

To get the timeline to reverse on click, you need to add a click event listener on the element. 

 

Altogether you'll get something like this:

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

 

I highly suggest going slowly through the GSAP getting started article:

 

I also highly suggest my article on article on animating efficiently because I think you'll learn a lot not only about GSAP but how to set things up correctly in JavaScript.

 

Happy tweening!

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