I'm making a simple HTML5 canvas drawing app for fun.
In my code, whenever I center the canvas with
margin: auto;
or
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
the mouse coordinates are shifted, and that shift, or offset, seems to be reliant upon on the size of the window.
Why are the mouse coordinates shifted?
Is there any way to prevent this, while still getting the same effect?