Skip to content

Commit

Permalink
Layout topology on browser resize
Browse files Browse the repository at this point in the history
* prevents nodes scaling indepently of graph size

Fixes #1096
  • Loading branch information
davkal committed Apr 12, 2016
1 parent d6eff06 commit 1c08c0c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions client/app/scripts/charts/nodes-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,10 @@ export default class NodesChart extends React.Component {
});
}

// _.assign(state, this.updateGraphState(nextProps, state));
if (nextProps.forceRelayout || nextProps.nodes !== this.props.nodes) {
_.assign(state, this.updateGraphState(nextProps, state));
const needsLayout = nextProps.forceRelayout
|| nextProps.width !== this.props.width || nextProps.height !== this.props.height;
if (needsLayout || nextProps.nodes !== this.props.nodes) {
_.assign(state, this.updateGraphState(nextProps, state, needsLayout));
}

if (this.props.selectedNodeId !== nextProps.selectedNodeId) {
Expand Down Expand Up @@ -314,7 +315,7 @@ export default class NodesChart extends React.Component {
return { edges, nodes };
}

updateGraphState(props, state) {
updateGraphState(props, state, needsLayout = false) {
const n = props.nodes.size;

if (n === 0) {
Expand All @@ -337,7 +338,7 @@ export default class NodesChart extends React.Component {
height: props.height,
scale: nodeScale,
margins: MARGINS,
forceRelayout: props.forceRelayout,
forceRelayout: needsLayout,
topologyId: this.props.topologyId,
topologyOptions: this.props.topologyOptions
};
Expand Down

0 comments on commit 1c08c0c

Please sign in to comment.