Created
January 17, 2018 20:08
-
-
Save neenjaw/a6427ea8358ac536cdf46bbd0618e884 to your computer and use it in GitHub Desktop.
JS for setting mouse-x/y css3 variable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var root = document.documentElement; | |
document.addEventListener("mousemove", evt => { | |
let x = evt.clientX / innerWidth; | |
let y = evt.clientY / innerHeight; | |
root.style.setProperty("--mouse-x", x); | |
root.style.setProperty("--mouse-y", y); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment