Skip to content

Commit

Permalink
Fire event when item becomes current (rel: #160)
Browse files Browse the repository at this point in the history
  • Loading branch information
LeaVerou committed Feb 3, 2024
1 parent 5154c12 commit 98f9a1b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions inspire.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -539,13 +539,15 @@ let _ = {
let item = _.items[_.item - 1];

item.classList.add("current");
item.dispatchEvent(new CustomEvent("itemcurrent", {bubbles: true}));

// support for nested lists
for (let i = _.item - 1, cur = _.items[i], j; i > 0; i--) {
j = _.items[i - 1];
if (j.contains(cur)) {
j.classList.remove("displayed");
j.classList.add("current");
j.dispatchEvent(new CustomEvent("itemcurrent", {bubbles: true}));
}
}

Expand Down

0 comments on commit 98f9a1b

Please sign in to comment.