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

[Question] Navigation invalid #86

Closed Maverickx0 closed 2 years ago

Maverickx0 commented 2 years ago

When I set hideMissingTitles as true, j/k/up/down will be invalid. It like below:

-- title 1 --- -- title 2 -- (hide title) -- title 3--

Like above, now focusing on title 2, when I use j/down to navigation, nothing happend.

Maverickx0 commented 2 years ago

ok, I had solved it !

Reveal.addEventListener('menu-ready', function (event) {
    var itemList = document.querySelectorAll("li.slide-menu-item");
        //OR document.querySelector(".slide-menu-items").querySelectorAll("li");
        var itemNum  = itemList.length;

    for (var i = 0; i < itemNum; i++) {
              var item = itemList[i];
              item.setAttribute("data-item", i+1);
        }
});