0
爲什麼當我點擊Raphael路徑元素的開頭或結尾時,座標不是我所期望的?見示例(http://jsfiddle.net/gharabed/prh2J/1/)爲什麼點擊座標不是我所期望的?
在example中,我有一條從(10,10)到(100,100)的路徑。如果我點擊100,100,100,100附近的路徑,我會得到類似(107,108)的點擊事件座標。我不能超過距離線的末端4或5個像素。事實上,它看起來像我只有2(可能最多3)像素。看起來座標有點偏離。我在這裏沒有考慮過什麼嗎?
function sendAlert(e) {
alert("Clicked at: " + e.x + "," + e.y + " I would expect it to be near the coordinates in the path defined (10,10) or (100,100)");
}
var paper = Raphael(document.getElementById('myid'),200,200);
var line = paper.path('M10,10L100,100');
line.attr({"stroke":"red","stroke-width":4});
line.click(sendAlert);
alert("Click as close as you can to the end of either end of the line segment.")
you'v得到關於文件的座標,而不是關於svg -element。在身體的例子有8px的邊緣 - 它給出了區別。只需使用svg元素的位置來修正座標 –