mousemove event js get x value code example
Example 1: javascript canvas mousemove
var canv = document.getElementById('my_canvas');
canv.addEventListener('mousemove', e => {
console.log({x:e.offsetX, y:e.offsetY, z:e})
});
var canv = document.getElementById('my_canvas');
canv.addEventListener('touchmove', e => {
ee = e.touches[0];
console.log({x:ee.clientX, y:ee.clientY, z:e})
});
Example 2: svg clientx
var pt = svg.createSVGPoint();
function alert_coords(evt) {
pt.x = evt.clientX;
pt.y = evt.clientY;
var cursorpt = pt.matrixTransform(svg.getScreenCTM().inverse());
console.log("(" + cursorpt.x + ", " + cursorpt.y + ")");
}