Skip to content

Commit

Permalink
More code commenting.
Browse files Browse the repository at this point in the history
  • Loading branch information
00Fjongl committed Jul 8, 2024
1 parent 75b8703 commit e9e5499
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
15 changes: 10 additions & 5 deletions views/assets/js/card.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,27 @@

const shimmerEffects = document.querySelectorAll(".box-card");


// Attach CSS variables, mouse-x and mouse-y, to elements that will be
// given shimmer effects, by adding or modifying the style attribute.
// CSS calculates and renders the actual shimmer effect from there.
shimmerEffects.forEach(shimmerEffect => {
shimmerEffect.addEventListener("mousemove", handleMouseMove);
shimmerEffect.addEventListener("mouseleave", handleMouseLeave);
});

function handleMouseMove(e) {
// Track the cursor position with respect to the top left of the card.
// The "this" keyword gets the element that invoked the event listener.
const handleMouseMove = e => {
const rect = this.getBoundingClientRect();
const x = e.clientX - rect.left;
const y = e.clientY - rect.top;

this.style.setProperty("--mouse-x", `${x}px`);
this.style.setProperty("--mouse-y", `${y}px`);
}
};

function handleMouseLeave() {
// Reset the cursor tracking variables when the cursor leaves the card.
const handleMouseLeave = () => {
this.style.setProperty("--mouse-x", `50%`);
this.style.setProperty("--mouse-y", `50%`);
}
};
4 changes: 2 additions & 2 deletions views/assets/js/common-16451543478.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
/* MAIN Holy Unblocker LTS Common Script
/* ----------------------------------------------- */

// Completely unused for some reason???
// const tryGetElement = id => document.getElementById(id) || {};
// Used in scripts outside this file.
const tryGetElement = id => document.getElementById(id) || {};

/**
* Get the preferred apex domain name.
Expand Down

0 comments on commit e9e5499

Please sign in to comment.