If events is set to true in the options, Gumshoe emits custom DOM events when navigation items are activated or deactivated. These events are dispatched from the parent <li> of the navigation link.
Events
gumshoeActivate: Dispatched when a navigation item and its content become active.gumshoeDeactivate: Dispatched when a navigation item and its content are no longer active.
Event Detail
The detail object contains:
link: The navigation element (the <a> tag).content: The content element being activated/deactivated.settings: The Gumshoe settings object used for this instance.
var gumshoe = new Gumshoe('.nav-link', { events: true });
// Listen for activation on the document or a specific container
document.addEventListener('gumshoeActivate', function (event) {
console.log('Activated:', event.detail.link);
console.log('Content:', event.detail.content);
});
document.addEventListener('gumshoeDeactivate', function (event) {
console.log('Deactivated:', event.detail.link);
});