问题
This is the code that is working on google chrome
var pointer = canvas.getPointer(event.e);
var posiX = pointer.x;
var posiY = pointer.y;
posiX=Math.round( posiX );
posiY=Math.round( posiY );
On mozzila i am getting "TypeError: event is undefined" and it is pointing at var pointer = canvas.getPointer(event.e);
回答1:
Dime,
Please use mouse events like this:
canvas.on('mouse:down', function(event){
var pointer = canvas.getPointer(event.e);
var posiX = pointer.x;
var posiY = pointer.y;
posiX=Math.round( posiX );
posiY=Math.round( posiY );
});
'event' has to be defined as part of the function parameter. Please make sure you have the same logic.
来源:https://stackoverflow.com/questions/41636200/how-to-get-fabric-js-canvas-mouse-cordinates-on-mozzila