Jump to content
Search Community

Toggle menu

jack_grechi 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

I'm not quite sure what you're trying to accomplish here. Are the items 1, 2, 3, and 4 supposed to be hidden until you click on the "toggle" div? What would be the point of the "toggle" div if you can click directly on each item?

 

 

You actually don't need GSAP at all if you're just looking to make a simple dropdown menu:

 

https://www.w3schools.com/howto/howto_js_dropdown.asp

Link to comment
Share on other sites

That's just a ternary operator. We say "is the tween reversed?" If true, we play the tween. If false, we reverse the tween.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator

 

It's a shorter way of writing this:

function doCoolStuff() {
  if (tween.reversed()) {
    tween.play();
  } else {
    tween.reverse();
  }
}

 

Make sense? Happy tweening.

  • Like 2
Link to comment
Share on other sites

3 minutes ago, PointC said:

That's just a ternary operator. We say "is the tween reversed?" If true, we play the tween. If false, we reverse the tween.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator

 

It's a shorter way of writing this:


function doCoolStuff() {
  if (tween.reversed()) {
    tween.play();
  } else {
    tween.reverse();
  }
}

 

Make sense? Happy tweening.

yes, thank you very much!

  • Like 2
Link to comment
Share on other sites

1 hour ago, jack_grechi said:

responsive don't work..

what is my mistake? 

 

Can you be a bit more clear? I have no clue as to what you are expecting when you say that. When I resize the screen, the toggle button appears and disappears as expected.

Link to comment
Share on other sites

6 minutes ago, Dipscom said:

 

Can you be a bit more clear? I have no clue as to what you are expecting when you say that. When I resize the screen, the toggle button appears and disappears as expected.

does not work if you try to open the toggle button and resize. 

Link to comment
Share on other sites

Again, I am at a loss here.

 

I open your codepen, resize the window to be smaller than 768px, the toggle appears, I click it. It animates. I click it again it closes. I resize the window to be bigger than 768px, the toggle disappears. I resize it back to be smaller than 768px, the toggle appears. I click it, the menu opens, I resize the window to be bigger than 768px, the toggle button disappears and the menu stays showing. I resize the window back to be smaller than 768px, the toggle button shows, I click it, it closes the menu.

 

I can't think of anything else I could do with the toggle button and the size of the window. What is it that is not working for you? In more words. What are you expecting to see and what is it doing that you think it should not be doing?

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