javascript - How can I bind a Raphael element to the mouse cursor? -


i want create element , have element bound cursor. have tools move element, don't know how bind them cursor without having click element. thought simulating mousedown() event, don't know how it.

for context, ultimate goal create line user defined endpoint. user clicks point , 2 small black circles created. 1 reference point the first click , other attached cursor path connect 2 points. once user clicks point, both small black circles disappear , line remain.

any ideas?

thanks @joan charmant pointing me in right direction. here's solution far. $('#paper') canvas , temppoint circle created bind cursor movement.

$("#paper").mousemove(function (event)                 {                     if(firstlinepointselected && temppoint!=null)                     {                         if (!event) var event = window.event;                         var x=0, y=0;                         if (event.pagex || event.pagey)                              {                             x = event.pagex;                             y = event.pagey;                         }                         else if (event.clientx || event.clienty)                             {                                                        x = event.clientx + document.body.scrollleft                                 + document.documentelement.scrollleft;                             y = event.clienty + document.body.scrolltop                                 + document.documentelement.scrolltop;                         }                          // subtract paper coords on page                         temppoint.attr("cx", x - $('#paper').offset().left);                         temppoint.attr("cy", y - $('#paper').offset().top);                     }                 }); 

Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

jquery - How would i go about shortening this code? And to cancel the previous click on click of new section? -