denehyg / reveal.js-menu

Slide out menu for reveal.js
https://denehyg.github.io/reveal.js-menu
MIT License
281 stars 76 forks source link

Is it possible to hide the Menu's button? #74

Open jamespascoe opened 3 years ago

jamespascoe commented 3 years ago

Hi there,

Apologies if this has been answered elsewhere, but is it possible to hide the menu's hamburger button on an individual slide? I am giving a talk at a conference that has asked me to use a particular title slide - the idea being that all of the talks start with a uniform look-and-feel. Because of this, I would like to be able to hide the menu's button (on the title slide) and then have the button appear on all of the other slides.

I noticed that I can use the 'delayInit' configuration parameter to prevent the menu from initialising when the presentation loads. Then, once the user has advanced beyond the title slide, I can call 'initialiseMenu()' to start the menu plugin from that point onwards. This works fine, except that once the Menu has been initialised, if I go back to the title slide, the icon is present. Is there a good way to hide (and unhide) the menu's button?

Many thanks and take care,

Jim

adgaudio commented 3 years ago

My comment is 22 days late, so you've probably figured this out already. My solution is to create a css class and javascript callback:

  <section class="hide-menu-button"> test slide 2 </section>

and this javascript:

    Reveal.on( 'slidetransitionend', event => {
      var menubutton = document.getElementsByClassName("slide-menu-button")[0]
      // store default display setting
      if (typeof(menubutton.__stored_display) == "undefined") {
          menubutton.__stored_display = menubutton.style.display;
      }
      if (event.currentSlide.classList.contains("hide-menu-button")) {
        console.log("current slide hide");
          menubutton.style.display = 'none';
      } else if (event.previousSlide.classList.contains("hide-menu-button")) {
        console.log("current slide show");
        menubutton.style.display = menubutton.__stored_display;
      }
    });
adgaudio commented 3 years ago

For the above, I wonder if it makes sense to add it to the reveal.js-menu as a default option?