Created
July 9, 2018 22:19
-
-
Save hoqqanen/36284d8391bd314f9315cb1541004e05 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
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