In chrome canary, layerX and layerY are deprecated, but what should we use instead ?
I\'ve find offsetX but it doesn\'t work with Firefox. So to get layerX without w
Here is a function to calculate layerX and layerY from a click event:
function getOffset(evt) {
var el = evt.target,
x = 0,
y = 0;
while (el && !isNaN(el.offsetLeft) && !isNaN(el.offsetTop)) {
x += el.offsetLeft - el.scrollLeft;
y += el.offsetTop - el.scrollTop;
el = el.offsetParent;
}
x = evt.clientX - x;
y = evt.clientY - y;
return { x: x, y: y };
}
Thanks a lot to Stu Cox for pointing out the two functions used to make this one.