Created
January 30, 2020 08:58
-
-
Save florinpop17/665cfab1ccdea8d548a54ae5c582e8ba to your computer and use it in GitHub Desktop.
Zoom Effect
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
const { body } = document; | |
let zoomActivated = false; | |
window.addEventListener('keydown', (e) => { | |
if(e.key === 'z') { | |
zoomActivated = !zoomActivated; | |
} | |
}); | |
window.addEventListener('mousemove', (e) => { | |
const { clientX: x, clientY: y } = e; | |
if(zoomActivated){ | |
body.style.transform = 'scale(2)'; | |
body.style.transformOrigin = `${x}px ${y}px`; | |
} else { | |
body.style.transform = 'none'; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment