开发者

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

开发者 https://www.devze.com 2023-02-13 18:59 出处:网络
i\'m using the excellent raphaeljs library and after having created a path with var c = paper.path(\"M10 10L90 90 ..... z\");

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 relativ开发者_如何学Pythone to raphael's canvas. Any idea? thx


Something like

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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消