Skip to content

Instantly share code, notes, and snippets.

@mutoe
Forked from auchenberg/index.js
Last active June 4, 2020 03: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 mutoe/4b9f8123da4ae25f9035b2a77f68447f to your computer and use it in GitHub Desktop.
Save mutoe/4b9f8123da4ae25f9035b2a77f68447f to your computer and use it in GitHub Desktop.
window.onwheel = function (e) {
e.preventDefault();
if (e.ctrlKey) {
// Your zoom/scale factor
scale -= e.deltaY * 0.01;
} else {
// Your trackpad X and Y positions
posX -= e.deltaX * 2;
posY -= e.deltaY * 2;
}
render();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment