Skip to content

Instantly share code, notes, and snippets.

@hoqqanen
Created July 9, 2018 22:19
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 hoqqanen/36284d8391bd314f9315cb1541004e05 to your computer and use it in GitHub Desktop.
Save hoqqanen/36284d8391bd314f9315cb1541004e05 to your computer and use it in GitHub Desktop.
function mouseDown(c, f) {
c.addEventListener("mousedown", e => {
f({x: e.pageX, y: e.pageY});
});
c.addEventListener("touchstart", e => {
f({x: e.touches[0].pageX, y: e.touches[0].pageY});
});
}
function mouseMove(c, f) {
c.addEventListener("mousemove", e => {
f({x: e.pageX, y: e.pageY});
});
c.addEventListener("touchmove", e => {
e.preventDefault();
f({x: e.touches[0].pageX, y: e.touches[0].pageY});
});
}
function mouseUp(c, f) {
c.addEventListener("mouseup", e => {
f();
});
c.addEventListener("touchend", e => {
f();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment