Skip to content

Commit

Permalink
Better sspotlight radius logic
Browse files Browse the repository at this point in the history
  • Loading branch information
DustinBrett committed Mar 1, 2024
1 parent 8ab6e1c commit 325047b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions utils/spotlightEffect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const spotlightEffect = (
highlightHovered &&
document.elementFromPoint(clientX, clientY) === element;

element.style.borderImage = `radial-gradient(150% 150% at ${clientX - x}px ${clientY - y}px, rgba(${hovered ? "255, 255, 255, 80%" : "150, 150, 150, 60%"}), transparent) 1 / ${border}px / 0 stretch`;
element.style.borderImage = `radial-gradient(75px at ${clientX - x}px ${clientY - y}px, rgba(${hovered ? "255, 255, 255, 80%" : "200, 200, 200, 60%"}), transparent) 1 / ${border}px / 0 stretch`;
} else {
document.removeEventListener("mousemove", mouseMove);
document.removeEventListener("mouseleave", removeStyle);
Expand All @@ -37,7 +37,7 @@ export const spotlightEffect = (
} else {
const mouseMove = ({ offsetX: x, offsetY: y }: MouseEvent): void => {
element.style.background = `radial-gradient(circle at ${x}px ${y}px, rgba(200, 200, 200, 30%), transparent)`;
element.style.borderImage = `radial-gradient(50% 75% at ${x}px ${y}px, rgba(200, 200, 200, 60%), transparent) 1 / ${border}px / 0 stretch`;
element.style.borderImage = `radial-gradient(75px at ${x}px ${y}px, rgba(200, 200, 200, 60%), transparent) 1 / ${border}px / 0 stretch`;
};

element.addEventListener("mousemove", mouseMove, PASSIVE);
Expand Down

0 comments on commit 325047b

Please sign in to comment.