Created
July 22, 2023 11:42
-
-
Save apsolut/ad4bab62b439b7b0a410b99fc0e5e597 to your computer and use it in GitHub Desktop.
cognigy: js accordion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// core version | |
import { gsap } from "gsap"; | |
import { Flip } from "gsap/flip"; | |
gsap.registerPlugin(Flip); | |
// Accordion for Task | |
const groups = gsap.utils.toArray(".accordion-group"); | |
groups.forEach(el => { | |
el.addEventListener("click", () => toggleMenu(el)); | |
}); | |
function toggleMenu(el) { | |
let state = Flip.getState(el.querySelector(".accordion-content")); | |
el.classList.toggle("active"); | |
Flip.from(state); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment