Jump to content
Search Community

Stop autoplaying mobile menu

phillip_vale test
Moderator Tag

Go to solution Solved by ZachSaucier,

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

Hello phillip_vale, and Welcome to the GreenSock Forum

 

You would need to follow the great advice from ZachSaucier above about reversed.

 

And you need to set the paused: true state to your timeline, very important!

 

See the Pen wMZqVg by jonathan (@jonathan) on CodePen


 

var menu = new TimelineMax({
    paused: true // set timeline to a paused state
  })
  .from("#mobmenu", 1, {
    height: 0,
    ease: Power2.easeInOut,
    immediateRendder: false
  })
  .from("#mobicon", 1, {
    rotation: -45,
    ease: Power2.easeInOut,
    immediateRendder: false
  }, 0)
  .reversed(true); // add reversed state at end of timeline

function menuFunction() {
  menu.reversed() ? menu.play() : menu.reverse();
}

Hope this helps! :)

  • Like 3
Link to comment
Share on other sites

Another tip. If you add reverse() to the end, you don't have to pause it.

var menu = new TimelineMax()
  .from("#mobmenu", 1, {
    height: 0,
    ease: Power2.easeInOut,
    immediateRendder: false
  })
  .from("#mobicon", 1, {
    rotation: -45,
    ease: Power2.easeInOut,
    immediateRendder: false
  }, 0)
  .reverse();

function menuFunction() {
  menu.reversed(!menu.reversed());
}

See the Pen 6d8f73d30fe2dccbcd8fa154adbb8815 by osublake (@osublake) on CodePen

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