Jump to content
Search Community

unexpected behavior/am i doing this right?

m4rsibar 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

Playing around ive manage almost get the desired effect im going for. 

 

simply: when one menu is opened, the other closes, vice versa.

 

i'm not sure this is the best way of doing things (if you'll be so kind to look at the code in the codepen ive tried to comment to make it easier)

 

the problems: when clicking quickly back and forth between the two buttons everything gets glitchy/janky.  i'm very new to this library any pointers in the right direction are appreciated.

See the Pen zyPBoz?editors=0010 by m4rsibar (@m4rsibar) on CodePen

Link to comment
Share on other sites

since you only have 2 buttons you can probably get away with just resetting the menu you don't want to show and restart the one you do want to show like

//cold button event listener
coldButton.addEventListener('click',e=>{
   showHotMenu.pause(0)
    showColdMenu.restart()
 
});

//hot button event listener
hotButton.addEventListener('click',e=>{
  showColdMenu.pause(0)
    showHotMenu.restart()
});

 

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

 

As you get more advanced it might look nicer to reverse the currently open animation.

 

See this post from @OSUBlake

 

 

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