Removed getCursorPosition

This commit is contained in:
unsettledgames
2021-07-22 19:05:58 +02:00
parent 15cca5ffb7
commit 6b84cdaa4d
8 changed files with 43 additions and 41 deletions

View File

@ -22,6 +22,25 @@ const Input = (() => {
dragging = false;
}
function getCursorPosition(e) {
var x;
var y;
if (e.pageX != undefined && e.pageY != undefined) {
x = e.pageX;
y = e.pageY;
}
else {
x = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
y = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
}
x -= currentLayer.canvas.offsetLeft;
y -= currentLayer.canvas.offsetTop;
return [Math.round(x), Math.round(y)];
}
/** Just listens to hotkeys and calls the linked functions
*
* @param {*} e
@ -155,6 +174,7 @@ const Input = (() => {
return {
spacePressed,
isDragging,
getCurrMouseEvent
getCurrMouseEvent,
getCursorPosition
}
})();