I have found this question that answers how to determine mouse movement on up, right, down, and left but I need the diagonals rather than the four straight directions.
Here's my code:
var deltaX = window.mxShapeRes - event.offsetX,
deltaY = window.myShapeRes - event.offsetY;
if (Math.abs(deltaX) > Math.abs(deltaY) && deltaX > 0) {
//left
} else if (Math.abs(deltaX) > Math.abs(deltaY) && deltaX < 0) {
//right
} else if (Math.abs(deltaY) > Math.abs(deltaX) && deltaY > 0) {
//up
} else if (Math.abs(deltaY) > Math.abs(deltaX) && deltaY < 0) {
//down
}
I need to determine if the mouse is going top-left, top-right, bottom-left or bottom-right.
How can I do this with the given code?
Thanks for anyone that can help!