Mermoz
Mermoz

Reputation: 15474

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

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

Upvotes: 0

Views: 872

Answers (1)

macarthy
macarthy

Reputation: 3069

Something like

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

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

Upvotes: 2

Related Questions