Jump to content
Search Community

ToggleClass Button

Sukru test
Moderator Tag

Go to solution Solved by Rodrigo,

Recommended Posts

Hello, I want to close the content that I opened with the Menu button with the same button.

I use scroll pause when opening the menu, but to cancel it "smoother.paused(false);" I have to use is there a method like toggleclass for this?

Can you help me?

 

The code i use;


 

$(".hamburgerMenuOpen").click(function () {
    smoother.paused(true);
    $(".menu").addClass("visible");
  });

  //Hamburger Menu Close
  $(".hamburgerMenuClose").click(function () {
    smoother.paused(false);
    $(".menu").removeClass("visible");
  });

 

See the Pen poKybZq by sukruemanet (@sukruemanet) on CodePen

Link to comment
Share on other sites

  • Solution

Hi,

 

Based on @Trapti's codepen just create a boolean to pause/unpause the ScrollSmoother instance:

// Menu is closed by default so the Smoother shouldn't be paused
let isPaused = false;

$(".hamburgerMenuOpen").click(function () {
  isPaused = !isPaused;
  smoother.paused(isPaused);
  $(".menu").toggleClass("visible");
});

Happy Tweening!

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