Created
March 31, 2019 15:36
-
-
Save bedekelly/fea6720083392e11062f0af23ecc62fd to your computer and use it in GitHub Desktop.
Parallax Event Listeners
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
document.addEventListener("mousemove", event => { | |
const height = event.clientY / window.innerHeight; | |
const width = event.clientX / window.innerWidth; | |
updatePositions(height, width); | |
}); | |
window.addEventListener("deviceorientation", event => { | |
const height = -event.beta / 90; | |
const width = event.gamma / 180; | |
updatePositions(height, width); | |
}, true); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment