Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 142188

Binding a line to the positions of two other SVG objects. Is there a way to easily express this with SVG, Javascript or any other library?

$
0
0

When using the SVG API, I can create a line going from point (x1,y1) to (x2,y2). I may be doing this because (x1,y1) corresponds to the place where I have an object A and (x2,y2) to a place where there's an object B.

It may happen that during an animation I then move object A to a different place. The problem is that then the line drawn between A and B will not get automatically updated.

I would like to know if there is a way through SVG, JS, or some existing library, to be able to express that a given line should connect object A and B, and if I move them around, the line should automatically get updated.

This is not really tied only to animations -- I may want to put a bunch of objects in some set of positions and it's just easier to say that I want to connect A to B than having to repeat the coordinates around.

Of course, the line here was just an example, I'd be looking to be able to do this for a whole range of other cases.

Thanks


Viewing all articles
Browse latest Browse all 142188

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>