Skip to content

Hooks!

Compare
Choose a tag to compare
@Twikito Twikito released this 14 Jul 14:55
· 285 commits to master since this release

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);