I have tried to draw an image in my canvas then try to click inside the image with the mouse. But the X and Y positions are not correct, i took offset's into consideration and corrected for that but they are still incorrect.
I currently don't know how else to solve it. I have made a fiddle to replicate the situation including the parent div the canvas resides inside of.
The code i used to take offset into consideration, which appears not to be working:
function getxy(event,el){
canvasX = event.pageX - el.offsetLeft,
canvasY = event.pageY - el.offsetTop;
return {x:canvasX, y:canvasY}
//does not give the same answer as you would expect when using drawImage();
}
In the fiddle the top left corner of the canvas should be 0,0
but it is not according to my calculation i used.