Closed waj334 closed 3 years ago
Thanks @waj334
Its an interesting concept, would you be able to give me a working gist so that I can test and correct the implementation
I doubt you'd need the whole implementation of my drag and drop, so you could probably replicate the behavior by just adding a node from the onDragStart function on a Draggable and removing it in onDragCompleted.
I think for my use case though, I want to not have the nodes automatically positioned so that I can allow the user to place them where ever they want. I assume I need a custom Layout that just does nothing?
I called right. Using a Layout that does nothing is exactly what I wanted.
class DumbGraphAlgorithm implements Layout { DumbGraphAlgorithm({this.renderer}) { renderer = renderer ?? ArrowEdgeRenderer(); }
@override EdgeRenderer renderer;
@override Size run(Graph graph, double shiftX, double shiftY) { return calculateGraphSize(graph); }
@override void setFocusedNode(Node node) { //Do nothing }
Size calculateGraphSize(Graph graph) { var left = double.infinity; var top = double.infinity; var right = double.negativeInfinity; var bottom = double.negativeInfinity;
graph.nodes.forEach((node) {
left = min(left, node.x);
top = min(top, node.y);
right = max(right, node.x + node.width);
bottom = max(bottom, node.y + node.height);
});
return Size(right - left, bottom - top);
} }
Nice
I'm implementing a drag and drop interface and I'm noticing that nodes tend to shift positions as edges are created. Is there a way to fix the position of the existing node when using it to create a new edge?
Great library btw!