Skip to content

Instantly share code, notes, and snippets.

@florinpop17
Created January 30, 2020 08:58
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 florinpop17/665cfab1ccdea8d548a54ae5c582e8ba to your computer and use it in GitHub Desktop.
Save florinpop17/665cfab1ccdea8d548a54ae5c582e8ba to your computer and use it in GitHub Desktop.
Zoom Effect
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