How to update the lines so that they do not break away from the rectangles after dragging?

Can you share a screenshot and a live example of what you have so far? Thanks!