menuspy
menuspy copied to clipboard
Side Menu : Bug section title problem after page refresh
Hi,
There is a problem after page refresh
How to reproduce : https://leocs.me/menuspy/examples/sidemenu.html click on the latest bullet (section-3) refresh the page click on any other bullet let say section-2 the section title 3 stay active while section are changing
Setting the active class name in the callback seems to fix this:
var sideNav = document.querySelector('#sideNav');
var ms = new MenuSpy(sideNav, {
callback: function(currentItem) {
var isCurrentItemActive = currentItem.elm.parentNode.classList.contains('active');
if (isCurrentItemActive) return;
sideNav
.querySelector('.active')
.classList.remove('active');
currentItem.elm.parentNode.classList.add('active');
},
});