const root = document.documentElement; let mouseX = 0; let mouseY = 0; document.addEventListener("mousemove", (evt) => { mouseX = evt.clientX / innerWidth; mouseY = evt.clientY / innerHeight; root.style.setProperty("--mouse-x", `${mouseX}`); root.style.setProperty("--mouse-y", `${mouseY}`); console.log(root.style.getPropertyValue("--mouse-x")); });