Jump to content
Search Community

Trying to reverse animate

RoaldKamman test
Moderator Tag

Recommended Posts

Hey, 

 

I'm just trying to make the arrow do the same 180degree rotation on a second click when closing and opening the navigation. So every time it gets clicked it rotates 180 degrees from where it's at. 

 

I'm not sure what the best method is for this. I tried yoyo() reverse() runBackwards() but I also can't get any of them to work.

 

Thanks

See the Pen vYLyZWB by RoaldKamman (@RoaldKamman) on CodePen

Link to comment
Share on other sites

Hey Roald. A few notes:

  • You're using the old GSAP formatting. We highly recommend the sleeker GSAP 3 formatting. Please see the migration guide for more info:
  • There's no point in using a stagger if you only have one target element.
  • If you want to reverse an animation, you should create the animation outside of the event listener and control the animation inside of the event listener. I write about how to do that in my article on animating efficiently which I highly recommend that you read.

Here's how I'd set it up:

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

 

FYI jQuery's animations are not the most performant. I might consider switching them over to GSAP ones that you make instead.

Link to comment
Share on other sites

4 minutes ago, RoaldKamman said:

sooo something lime this? except it throws and error for the closing bracket of the tl?

No, not like that. Nekiy2 was incorrect with what he said (you don't need a timeline) and your formatting is incorrect in several places. See the demo included in my post above for how to set things up.

  • Like 1
Link to comment
Share on other sites

this is getting more confusing with every second I reversed everything i did and only changed tweenLite to gsap.to. ALL I really want is to make sure it makes a 180 degree turn with every click.  

 

I have no clue what I'm supposed to look for within the 2 long blogsposts. It's pretty overwhelming as a beginner. Please be a little more specific.  

 

Nevermind I need a break. I just totally missed your example. let me extract the lessons from that. My  bad

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