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 /src/view/selection.js | |
| parent | dd51e5e964fbf3da32c4ccd8a8f71f9b1c30081f (diff) | |
fix selection inversion: Fixes #144
Diffstat (limited to 'src/view/selection.js')
| -rw-r--r-- | src/view/selection.js | 11 |
1 files changed, 9 insertions, 2 deletions
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); } } |
