I have a GlideJS carousel and I'm trying to call my handleAnimation
function after each slide becomes active.
It works if I click on it, but I don't know how to get it to run when the carousel is on autoplay.
componentDidMount = () => {
const carousel = new Glide(this.myRef.current, {
autoplay: 3000,
rewind: true,
})
carousel.mount()
const myTriggers = document.querySelectorAll(".slide__trigger")
myTriggers.forEach(trigger => {
const triggerStep = trigger.getAttribute("data-step")
trigger.addEventListener("click", () =>
this.handleAnimation(triggerStep)
)
})
}
Should I be using one of GlideJS's event handlers? Thanks for any advice!