Suppose something is being done on a sort of family tree. Those. connected blocks. Links are depicted in simple lines.
1) How to implement automatic line drawing. (Blocks are set on the page, and links are rendered depending on the blocks.)
2) How to redraw connections if blocks can be dragged?

Honestly, I do not even know where to start. For the simplest example, let's take that there are 2 square divs. It is necessary that their centers are connected by a line. And she was under div'ami.

  • one
    Hmm, canvas will help you draw lines. 1 - simulate how the connection will work and write a script for it accordingly. 2 - follows from point 1. Just re-draw the line. - lampa
  • 2
    @oleg_ismaylov, I think you need the Arrows-and-boxes plugin - Deonis

1 answer 1

It is easier to use Canvas in this case :) In Jquery, you can calculate coordinates relative to the parent :) Then you can work with these coordinates in Canvas, there are line drawing functions .. You can even draw a smooth line :) When dragging a block, you need to do recalculations: ) In fact, it is theoretically not so difficult :) It may seem tedious :)