Created
October 30, 2018 14:40
-
-
Save Monichre/c1667a03961f6072af9d28d3ae7a5fed to your computer and use it in GitHub Desktop.
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
var tx = 0; | |
var ty = 0; | |
var scale = 1; | |
document.addEventListener('wheel', function (e) { | |
e.preventDefault(); | |
if (e.ctrlKey) { | |
var s = Math.exp(-e.deltaY / 100); | |
scale *= s; | |
console.log("delta = " + e.deltaY); | |
console.log("scale = " + scale); | |
console.log("s = " + s); | |
} else { | |
var direction = natural.checked ? -1 : 1; | |
tx += e.deltaX * direction; | |
ty += e.deltaY * direction; | |
} | |
var transform = 'translate(' + tx + 'px, ' + ty + 'px) scale(' + scale + ')'; | |
box.style.webkitTransform = transform; | |
box.style.transform = transform; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment