summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Michelotti <michelotti.matthew@gmail.com>2018-07-21 23:21:57 -0500
committerMatthew Michelotti <michelotti.matthew@gmail.com>2018-07-21 23:22:04 -0500
commit3c81c89df58459f38eace94af2fbf9c1fc65ed3f (patch)
tree61f3929882f7df0b2c4f879d1c37d657afbec193
parent40a2422cfe5619d9dae899bf1ce0146a0fdf7ef3 (diff)
corrected cursor position on html canvas
-rw-r--r--gate_build/src/html/gate.js8
1 files changed, 4 insertions, 4 deletions
diff --git a/gate_build/src/html/gate.js b/gate_build/src/html/gate.js
index d6e9c97..f288596 100644
--- a/gate_build/src/html/gate.js
+++ b/gate_build/src/html/gate.js
@@ -344,15 +344,15 @@ function gate(args) {
function handleMouseMotion(evt) {
if (Module.currentlyRunning) {
- cursorPos.x = evt.clientX;
- cursorPos.y = evt.clientY;
+ cursorPos.x = evt.clientX * (canvas.width / canvas.clientWidth);
+ cursorPos.y = evt.clientY * (canvas.height / canvas.clientHeight);
}
}
function handleMouseEvent(evt, down) {
if (Module.currentlyRunning) {
- cursorPos.x = evt.clientX;
- cursorPos.y = evt.clientY;
+ cursorPos.x = evt.clientX * (canvas.width / canvas.clientWidth);
+ cursorPos.y = evt.clientY * (canvas.height / canvas.clientHeight);
const continuing = Module.gateWasmMouseEvent(cursorPos.x, cursorPos.y, evt.button, down)
if (!continuing) {
quitApp();