Note that there are some explanatory texts on larger screens.

plurals
  1. POmaking one side of a path draggable in Raphael 2.0
    primarykey
    data
    text
    <p>I am reading a JSON file and foreach element I am creating a path and a circle. I need to make the path drag with the circle. The path terminates at the exact x,y coordinates of the circle center. I only want the circle end of the path to drag with the circle. The other end of the path is fixed. </p> <p>I have drag working for the circles but it is not doing anything for the paths. I have posted code that is dumbed down and does not contain the intelligence for positioning circles. I only need help with dragging one end of the path. My script is reading the JSON fine and painting the canvas with circles and paths at the correct coordinates. Thanks in advance for your help.</p> <p>I do not answers that require an additional plug in please.</p> <pre><code>&lt;script type="text/javascript"&gt; $.getJSON('jsonScript.php?view=json', function( json ){ var start = function () { this.ox = this.attr("cx"); this.oy = this.attr("cy"); this.animate(); }, move = function (dx, dy) { this.attr({cx: this.ox + dx, cy: this.oy + dy}); }, up = function () { this.animate(); }; var paper = Raphael( canvas.leftMargin, canvas.topMargin, canvas.width, canvas.height ); $.each( json, function( a , z ) { var circleObj = paper.circle( x, y, radius ); circleObj.attr({"fill":"black","stroke":"red","stroke-width":5}); circleObj.node.id = jsonVar; var pathObj = paper.path( "M396,16L641,187" ); path.attr({"stroke":"#fdfdfd","stroke-width":3}).toBack(); paper.set( circleObj, pathObj ).drag( move, start, up ) }); }); &lt;/script&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload