How do I get mouse coordinates on Fabric.js?
fabricjs, html5-canvas, javascript, jquery
Solution
The best fix is this method
Implementation:
function getMouseCoords(event)
{
var pointer = canvas.getPointer(event.e);
var posX = pointer.x;
var posY = pointer.y;
console.log(posX+", "+posY); // Log to console
}
Problem
I'm trying to read the X coordinate of a mouse click on Fabric.js. Here is my code. The console logs `undefined` every time. ``` var canvas = new fabric.Canvas('c1'); canvas.on('mouse:down', function(e){ getMouse(e); }); function getMouse(e) { console.log(e.clientX); } ```