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

RevealMenu.toggle is not a function #67

Closed rajgoel closed 4 years ago

rajgoel commented 4 years ago

Hi Greg, I'm in the process of updating my plugins and demos to reveal.js 4 and noticed that I cannot use RevealMenu.toggle() as desribed in #35. You can reproduce the issue, e.g., here.

Can it be that the toggle function is no longer exposed? Or am I doing something wrong?

Cheers Asvin

denehyg commented 4 years ago

Hi Asvin,

I updated this plugin to work with the new plugin API in Reveal v4. To get access to the menu plugin from within your presentation you'll need to use Reveal.getPlugin('menu') in place of RevealMenu (as you would have previously done).

My presentations use the following...

<script>
  toggleMenu = () => {
    let menu = Reveal.getPlugin('menu');
    if (menu) menu.toggle();
  };
</script>
<a href="#" onclick="toggleMenu(); return false;">Menu</a>

I clearly forgot to update the docs for this when I updated. I'll make an effort to do this soon. Thanks for catching it.

rajgoel commented 4 years ago

Excellent, thanks!