svg clientx

Solutions on MaxInterview for svg clientx by the best coders in the world

showing results for - "svg clientx"
Klara
19 Apr 2020
1var pt = svg.createSVGPoint();  // Created once for document
2
3function alert_coords(evt) {
4    pt.x = evt.clientX;
5    pt.y = evt.clientY;
6
7    // The cursor point, translated into svg coordinates
8    var cursorpt =  pt.matrixTransform(svg.getScreenCTM().inverse());
9    console.log("(" + cursorpt.x + ", " + cursorpt.y + ")");
10}
Mats
07 Mar 2018
1function clicked(evt){
2    var e = evt.target;
3    var dim = e.getBoundingClientRect();
4    var x = evt.clientX - dim.left;
5    var y = evt.clientY - dim.top;
6    alert("x: "+x+" y:"+y);
7}