Skip to content

Commit fa32a0c

Browse files
committed
feat: Update card spotlight position on mousemove and wheel events.
1 parent ed18b9d commit fa32a0c

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/layouts/Layout.astro

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const { title } = Astro.props;
6464

6565
const cards = document.querySelectorAll("[data-spotlight]");
6666

67-
document.addEventListener("mousemove", (e) => {
67+
function handleCardsSpotlightPosition(e) {
6868
cards.forEach((card) => {
6969
const rect = card.getBoundingClientRect();
7070
const x = e.clientX - rect.left;
@@ -73,7 +73,10 @@ const { title } = Astro.props;
7373
card.style.setProperty("--x", `${x}px`);
7474
card.style.setProperty("--y", `${y}px`);
7575
});
76-
});
76+
}
77+
78+
document.addEventListener("mousemove", handleCardsSpotlightPosition);
79+
document.addEventListener("wheel", handleCardsSpotlightPosition);
7780
});
7881
</script>
7982
</body>

0 commit comments

Comments
 (0)