I am trying to implement a diagram similar to the vertical swim lanes sample as seen here:
Everything seems to be working fine, until I change the placeholder alignment for the Diagram’s groupTemplate from go.Spot.TopLeft to go.Spot.Center. The effect I am trying to achieve is to have the swim lanes align the contained nodes in the center of the swim lane, when the diagram is drawn. The side-effect of changing the placeholder’s alignment is that when a node in any of the swim lanes is dragged, the other nodes in the same lane move as well. If the alignment is set to TopLeft, then this does not happen.
To illustrate the side-effect better, I have created this jsfiddle, so that you can replicate easilly:
Try for example moving around any node inside Lane 1 and you will notice that when the node is dropped in a new position within the lane, the other nodes slightly move as well.
The example in the jsfiddle is an exact copy of the sample code in github:
The line of code I changed to achieve the Centered effect is 326 on github and 304 in the jsfiddle posted above.
Is there a way to still set the alignment to Centered for the diagram’s groupTemplate placeholder and not have the side-effect of the other nodes in the swim lane being re-positioned when moving a node?
I haven’t tried your code yet, but it seems to me that if something is centered, when you change its size by moving one of its nodes, then it makes sense that it (the Placeholder) has to move in order to keep it centered.
Yes, agreed, this would be an expected behavior. What I am trying to achieve is to have the placeholder center the items on the first draw, but then switch it to use go.Spot.TopLeft so that then the items are moved around it does not try to recenter them.
Do you have any suggestion on how I could make something like that?
Yes, that is exactly how I used the code snippet you posted. I used the same approach in the LaneResizingTool.prototype.resize method and that creates a nice visual effect of the swim lanes being resized equally on both the right and the left side. Pretty cool! Thank you @walter.