Jump to content
GreenSock

phillip_vale

onClick and reverse

Moderator Tag
Go to solution Solved by PointC,

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 am trying to do a simple nav that starts as a 'burger', animates to a cross and opens the menu on the right.

I would then i would like it to change back to a burger and hide menu if the cross is clicked or an item in the menu is clicked.

 

Does this involve switching between the onClick="menuIn()" and onClick="menuOut()" like they mention in this forum?

 

http://stackoverflow.com/questions/5303899/change-onclick-action-with-a-javascript-function

 

Am i even close?

 

Thanks for any help,

 

Phil

See the Pen ezNMEP by phillip_vale (@phillip_vale) on CodePen

Link to comment
Share on other sites

  • Solution

Hi phillip_vale :)

 

The easiest way to do that is alternate play/reverse of the timeline on click. Here's a fork of your pen with that solution:

 

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

 

Happy tweening.

:)

  • Like 3
Link to comment
Share on other sites

Hi PointC!

 

Thanks for this. Works a treat!

 

Except when i try to use it in my files on my desktop it doesn't seem to want to work. This happens to me alot when i copy code from greensock and into my files.

 

Is there some structure or heirachy that i am missing?

 

I stops working when i use it in the /js/script.js file but works fine if i put it on the bottom of the home page?

 

Thanks so much,

 

Phil

Link to comment
Share on other sites

Sorry i think i fixed it.

 

My script.js was loading before my jquery. :)

 

Thanks again!

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