Skip to content

Instantly share code, notes, and snippets.

@bedekelly
Created March 31, 2019 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bedekelly/fea6720083392e11062f0af23ecc62fd to your computer and use it in GitHub Desktop.
Save bedekelly/fea6720083392e11062f0af23ecc62fd to your computer and use it in GitHub Desktop.
Parallax Event Listeners
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