Hi, I am new to gsap and my problem is to replace addEventListener with @click event
data() {
return {
elements: [],
activeElement: null,
};
},
methods: {
categoryAnimationIsActive() {
this.elements = gsap.utils.toArray(".category__item");
this.activeElement = this.elements[0];
gsap.set(this.elements, {
y: 30
});
this.elements.forEach((el) => {
el.animation = gsap.to(el,{
y: 0,
paused: true
});
if (el === this.activeElement) {
el.animation.progress(1);
}
el.addEventListener("click", () => {
if (el !== this.activeElement) {
this.activeElement.animation.reverse();
el.animation.play();
this.activeElement = el;
}
});
});
}
},
mounted() {
this.categoryAnimationIsActive();
}