Hi, i have <ClientRouter /> on my Layout, so I understand that the scripts are only executed on the first render, that's why I use astro:page-load for example, then, why is this animation executed always if it's outside the astro:page-load event listener?
<script>
import { animate, stagger } from "motion";
animate(
".tripadvisor-image",
{
scale: [1, 1.05, 1],
},
{
duration: 0.8,
repeat: Infinity,
repeatDelay: 3,
ease: "easeInOut",
delay: stagger(0.2),
},
);
document.addEventListener("astro:page-load", () => {
const openModalButton = document.getElementById("open-tripadvisor-modal-button") as HTMLButtonElement | null;
if (openModalButton) {
openModalButton.addEventListener("click", () => {
window.dispatchEvent(new CustomEvent("open-tripadvisor-modal"));
});
}
});
</script>