Hi guys,
I created a component for my links and I integrated an embed code to manage the hover animation. I generated this GSAP code on ChatgGPT, but it doesn’t seem to work.
<script>
// 'wrapper' correspond au composant lui-même
const wrapper = document.currentScript.closest(".link-container");
if (wrapper) {
const link = wrapper.querySelector(".link");
const arrow = wrapper.querySelector(".link-arrow");
if (link && arrow) {
link.addEventListener("mouseenter", () => {
gsap.to(arrow, {
x: 5,
y: -5,
scale: 1.05,
duration: 0.1
});
});
link.addEventListener("mouseleave", () => {
gsap.to(arrow, {
x: 0,
y: 0,
scale: 1,
duration: 0.1
});
});
}
}
</script>
Does embed code work for GSAP animations ? Is there a problem with my code ?
Thanks,
Martin