[英]How can I display the mouse coordinates in fabric.js
嗨,我正在嘗試顯示或捕獲程序中的鼠標坐標。 在此程序中,您可以單擊任何按鈕,然后將出現相應的圖像。 我也想在此顯示鼠標坐標。
我嘗試了以下代碼,但是它不起作用。 請讓我知道我要去哪里了。
canvas.on('mouse:down', function(options){
getMouse(options);// its not an event its options of your canvas object
});
function getMouse(options) {
console.log(options);// you can check all options here
console.log(options.e.clientX);
}
小提琴是: http : //jsfiddle.net/wv9MU/9/
這可能是您的getMouse函數:
function getMouse(options) {
p = canvas.getPointer(options.e);
document.getElementById('mouse').value = '' + p.x.toFixed() + ', ' + p.y.toFixed(0);
}
這是一個未經修飾的工作小提琴。 http://jsfiddle.net/wv9MU/22/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.