Skip to content

Commit

Permalink
✨ Add centerGraph option
Browse files Browse the repository at this point in the history
  • Loading branch information
deje1011 committed Feb 26, 2021
1 parent bc95004 commit f357b97
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/cola.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,14 @@ ColaLayout.prototype.run = function(){
adaptor
.avoidOverlaps( options.avoidOverlap )
.handleDisconnected( options.handleDisconnected )
.start( options.unconstrIter, options.userConstIter, options.allConstIter)
.start(
options.unconstrIter,
options.userConstIter,
options.allConstIter,
undefined, // gridSnapIterations = 0
undefined, // keepRunning = true
options.centerGraph
)
;

if( !options.infinite ){
Expand Down
2 changes: 2 additions & 0 deletions src/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ let defaults = {
flow: undefined, // use DAG/tree flow layout if specified, e.g. { axis: 'y', minSeparation: 30 }
alignment: undefined, // relative alignment constraints on nodes, e.g. function( node ){ return { x: 0, y: 1 } }
gapInequalities: undefined, // list of inequality constraints for the gap between the nodes, e.g. [{"axis":"y", "left":node1, "right":node2, "gap":25}]
centerGraph: true, // adjusts the node positions initially to center the graph (pass false if you want to start the layout from the current position)


// different methods of specifying edge length
// each can be a constant numerical value or a function like `function( edge ){ return 2; }`
Expand Down

0 comments on commit f357b97

Please sign in to comment.