gextra
gextra

Reputation: 8913

D3 connect a line between two moving SVG elements

Is there a way to use D3 to connect a line between two moving elements and ensure they stay connected even if the elements move ( dynamically moved or manually dragged ) ?

Upvotes: 0

Views: 699

Answers (1)

Lars Kotthoff
Lars Kotthoff

Reputation: 109292

Yes. There is no notion of a connection between points as such, so the way to ensure that they stay connected would be to move the end points of the line with the elements. You simply need to update the position of the respective endpoint in the code that updates the position of the element.

Upvotes: 1

Related Questions