Raphaeljs: accessing the relative postion of a click on a closed path

会有一股神秘感。 提交于 2019-12-13 06:50:21

问题


i'm using the excellent raphaeljs library and after having created a path with

var c = paper.path("M10 10L90 90 ..... z");

i would like to get the position of the click event on the path relative to the canvas. I tried:

c.click(function (event) {
   alert(event.pageX);
}));

but that gives me a value which is not relative to raphael's canvas. Any idea? thx


回答1:


Something like

var x = Math.floor((event.pageX-$("#paper").offset().left));

Obviously this is using jQuerys $ to get the paper element..



来源:https://stackoverflow.com/questions/5146133/raphaeljs-accessing-the-relative-postion-of-a-click-on-a-closed-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!