17 lines
476 B
JavaScript
17 lines
476 B
JavaScript
document.addEventListener("DOMContentLoaded", () => {
|
|
const orb = document.querySelector(".hero-orb");
|
|
if (!orb || window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
|
|
return;
|
|
}
|
|
|
|
window.addEventListener(
|
|
"pointermove",
|
|
(event) => {
|
|
const x = (event.clientX / window.innerWidth - 0.5) * 18;
|
|
const y = (event.clientY / window.innerHeight - 0.5) * 12;
|
|
orb.style.translate = `${x}px ${y}px`;
|
|
},
|
|
{ passive: true }
|
|
);
|
|
});
|