Jump to content


toggle-able menu HELP please

Recommended Posts

So I'm wondering how I can create a menu like this (Yes, I did kinda copy stagger example from GSAP sorry) but for the .btn elements to initially not display (ie; display:none instead of just no size). then when the 'Click' button is pressed, the .btn elements animate onto the screen. I can get it to work once but after i have clicked one of the buttons and they off, they will not come back. 
Any help would be greatly appreciated.

See the Pen myOZgv by matt_panton (@matt_panton) on CodePen

Link to comment
Share on other sites

Hi and welcome to the GreenSock forums.


Thanks for providing the demo. Very helpful. looks like you are having fun ;)


The main problem here is that once you click any ".btn" to hide the menu you are tweening the alpha TO 0.

When you click "button" again, you are saying telling the ".btn" to tween FROM 0. If a property is at 0, tweening from 0 isn't going to do anything. In other words tweening from 0 to 0... leaves alpha at 0. 


Also, when you hide the menu you are tweening the height to 0 and display to none, but you are never setting those values back to what they should be in order to see the ".btn" again.


Fortunately there is a really easy fix for this. To set all the properties of all the ".btn" back to their initial, pre-tweened states, use 

TweenLite.set(".btn", {clearProps:"all"}) /// removes all inline-style properties set by GSAP

Take a look here: http://codepen.io/GreenSock/pen/PwWQpW




EDIT: BTW we love when people take our demos and experiment, its the best way to learn.

  • Like 2
Link to comment
Share on other sites

Thanks you for replying so fast!
I should of spotted that really, but your demo works perfect, 
thanks again, really appreciate it  :)  :D

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.