Problems with the dragging from the palette

Hi, I 've implemented two function :

  1. Auto add link when a node(node A) - dragged close to another (node B)

  2. Auto make 2 “bridge” links to replace 1 old link when a node is dragged onto an existing link
    that is : dragging a node C and positioning it in the middle of a link between node A and node B will do the following: 1) delete the link between A and B, 2) create link between A and C, 3) create link between C and B

The first function works fine if i drag a node (node A) that is already in the diagram close to another( node B) . But if i drag a node in a palette to the diagram and close to another node they are linked and when i “mouse-up” the link disappears.

The second function meet the same problem that it works fine with the node C in the diagram but when node C is in the palette the link disappears at last when i “mouse-up”

I don’t know why. Please help me with this.

you can see my example here: http://jsfiddle.net/thanhvu231/ufVUr/

That’s because the node that is being dragged from another diagram (such as the Palette) is a temporary copy; when the drop happens, the real node is made.

You must be adding a link that connects with the temporary node. When the temporary node is removed, the link(s) connected with it are removed too. You need to do the connection work for real when a drop happens, not during the drag, when you should create a temporary link. After all, the mouse up might happen at a different point than the last mouse move point, which might necessitate different effects such as linking with a different node.

If you haven’t defined your own custom DraggingTool, then you can do this in an “ExternalObjectsDropped” DiagramEvent listener. If you have defined your own DraggingTool, you can override the DraggingTool.doDropOnto method as well as the DraggingTool.doDragOver or moveParts methods. The http://gojs.net/latest/samples/pipes.html sample demonstrates customizing the DraggingTool, although for a different purpose and effect.

wow, great. I see. Thanks :)