I'm trying to write a simple java script program to mark rectangles on an image. You click a button to add a rectangle then you click on the upper left and lower right corner and the program should mark the rectangle in red. I'm using straight javascript with jquery.Everything almost works, except when either the upper left or lower right corner of a rectangle is inside another rectangle in that case, while the click event gets processed, the x and y are incorrect.I've been trying to troubleshoot this for hours and google didn't help. I specifically tried:
- changing the e.pageX for e.screenX and e.screenY
- using the absolute position (the top and left) instead of the offset