本文介绍了如何在Mozzila上获取fabric.js画布鼠标坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是在谷歌浏览器上运行的代码
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 );
在mozzila上,我收到"TypeError:事件未定义",它指向var指针= canvas.getPointer(event.e);
On mozzila i am getting "TypeError: event is undefined" and it is pointing atvar pointer = canvas.getPointer(event.e);
推荐答案
Dime,
请使用如下鼠标事件:
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.
这篇关于如何在Mozzila上获取fabric.js画布鼠标坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!