mirror of
https://github.com/projectstorm/react-diagrams.git
synced 2026-03-13 09:50:09 +08:00
Fixed a small positioning issue with dagre demo
The dagre example doesn't take into account that dagre works with center of position for nodes but react-diagrams works with top left of position for nodes. To correctly position the nodes, half of the width and height should be subtracted from the x and y axis respectively.
This commit is contained in:
@@ -11,8 +11,8 @@ export function distributeElements(model) {
|
||||
let nodes = distributeGraph(clonedModel);
|
||||
nodes.forEach(node => {
|
||||
let modelNode = clonedModel.nodes.find(item => item.id === node.id);
|
||||
modelNode.x = node.x;
|
||||
modelNode.y = node.y;
|
||||
modelNode.x = node.x - (node.width / 2);
|
||||
modelNode.y = node.y - (node.height / 2);
|
||||
});
|
||||
return clonedModel;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user