Skip to content

Commit

Permalink
chore: fix script
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Dec 8, 2023
1 parent 3b15023 commit fed6769
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions website/src/frontend-scripts/hover.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
var cards = document.querySelectorAll(".card");
// Yes TS I am a module.
export type {};

cards.forEach((card: any) => {
card.addEventListener("mousemove", (e: MouseEvent) => {
var x = e.pageX - card.offsetLeft;
var y = e.pageY - card.offsetTop;
card.style.setProperty("--x", x + "px");
card.style.setProperty("--y", y + "px");
});
});
const cards: NodeListOf<HTMLDivElement> = document.querySelectorAll(".card");

for (const card of cards) {
card.addEventListener("mousemove", (e: MouseEvent) => {
const x = e.pageX - card.offsetLeft;
const y = e.pageY - card.offsetTop;
card.style.setProperty("--x", `${x}px`);
card.style.setProperty("--y", `${y}px`);
});
}

0 comments on commit fed6769

Please sign in to comment.