diff options
| author | Alon Levy <alon@pobox.com> | 2014-12-04 00:03:01 +0200 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2014-12-04 00:06:03 +0200 |
| commit | c55355359ac1071200bd1ce04de78d3be1f43b52 (patch) | |
| tree | b227166efe8c3f0eea05bf54ae1b4ff2806d12e4 | |
| parent | dd51e5e964fbf3da32c4ccd8a8f71f9b1c30081f (diff) | |
fix selection inversion: Fixes #144
| -rw-r--r-- | src/rz_core.js | 2 | ||||
| -rw-r--r-- | src/view/selection.js | 11 |
2 files changed, 9 insertions, 4 deletions
diff --git a/src/rz_core.js b/src/rz_core.js index 276887ac..64bbc469 100644 --- a/src/rz_core.js +++ b/src/rz_core.js @@ -225,8 +225,6 @@ function update_view__graph(no_relayout) { }); view.edge_info.show(d); selection.update([src, dst]); - src.state = 'chosen'; - dst.state = 'chosen'; update_view__graph(true); }); diff --git a/src/view/selection.js b/src/view/selection.js index dfc043e1..32527631 100644 --- a/src/view/selection.js +++ b/src/view/selection.js @@ -28,7 +28,6 @@ function connectedComponent(nodes) { data; selection = true; - nodes.forEach(function (n) { n.state = 'chosen'; }); for (i = 0 ; i < connected.nodes.length ; ++i) { data = connected.nodes[i]; @@ -54,6 +53,7 @@ function connectedComponent(nodes) { break; }; } + nodes.forEach(function (n) { n.state = 'chosen'; }); } var node_selected = function(node) { @@ -75,9 +75,16 @@ function all(arr, pred) return arr.length == arr.filter(pred).length; } +function all_state(arr, state) +{ + return all(arr, function(a) { return a.state == state; }) +} + var update = function(nodes) { + // clear resets state + var set = !all_state(nodes, 'chosen'); clear(); - if (all(nodes, function(node) { return node.state != 'chosen'; })) { + if (set) { connectedComponent(nodes); } } |
