Hooks!
You can npw add some hooks: each trigger and target element fires a toggleBefore
event before and a toggleAfter
event after toggling its state, so you can add event listeners on these events, and test the active state with isToggleActive
property. For example:
document.querySelector("#myTrigger").addEventListener("toggleAfter", (event) => {
console.log(`Active: ${event.target.isToggleActive}`);
}, false);