diff options
| author | Alon Levy <alon@pobox.com> | 2015-04-12 00:23:33 +0200 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2015-04-12 00:23:44 +0200 |
| commit | 3255529f9db0208f8e56689e31aa626251ba1e40 (patch) | |
| tree | 365fd79e258513e21a7caa96627b499d071e8643 /src/client/view | |
| parent | 72ada9fea8741c2a5eaa96bd28d70f322d6622bb (diff) | |
client: zoom to selection button instead of automatic on selection
Diffstat (limited to 'src/client/view')
| -rw-r--r-- | src/client/view/graph_view.js | 14 | ||||
| -rw-r--r-- | src/client/view/selection.js | 5 |
2 files changed, 9 insertions, 10 deletions
diff --git a/src/client/view/graph_view.js b/src/client/view/graph_view.js index e69bacc9..6c2efa3e 100644 --- a/src/client/view/graph_view.js +++ b/src/client/view/graph_view.js @@ -776,8 +776,7 @@ function GraphView(spec) { in_view = segment_in_segment(scaled_low, scaled_high, screen_low, screen_high), new_scale; - new_scale = ((rect_high === rect_low || in_view) ? - current_scale : (screen_high - screen_low) / (rect_high - rect_low) * percent); + new_scale = (screen_high - screen_low) / (rect_high - rect_low) * percent; new_scale = Math.min(3, Math.max(0.1, new_scale)); return [ in_view @@ -790,11 +789,12 @@ function GraphView(spec) { ]; } - gv.nodes__user_visible = function(nodes) { + gv.nodes__user_visible = function(nodes, zoom_if_visible) { if (nodes.length == 0) { return; } - var xs = nodes.map(obj_take('x')), + var ratio_used = 0.8, + xs = nodes.map(obj_take('x')), ys = nodes.map(obj_take('y')), x_min = Math.min.apply(null, xs), x_max = Math.max.apply(null, xs), @@ -804,12 +804,12 @@ function GraphView(spec) { current_translate = zoom_obj.translate(), screen_width = $(document.body).innerWidth(), screen_height = $(document.body).innerHeight(), - x_data = scale_and_move(0, screen_width, x_min, x_max, 0.8, + x_data = scale_and_move(0, screen_width, x_min, x_max, ratio_used, current_scale, current_translate[0]), x_in_view = x_data[0], x_scale = x_data[1], x_translate_fn = x_data[2], - y_data = scale_and_move(0, screen_height, y_min, y_max, 0.8, + y_data = scale_and_move(0, screen_height, y_min, y_max, ratio_used, current_scale, current_translate[1]), y_in_view = y_data[0], y_scale = y_data[1], @@ -818,7 +818,7 @@ function GraphView(spec) { x_translate = x_translate_fn(min_scale), y_translate = y_translate_fn(min_scale); - if (!x_in_view || !y_in_view) { + if (zoom_if_visible || (!x_in_view || !y_in_view)) { set_scale_translate(min_scale, [x_translate, y_translate]); } } diff --git a/src/client/view/selection.js b/src/client/view/selection.js index 7585b50f..6a7fa01f 100644 --- a/src/client/view/selection.js +++ b/src/client/view/selection.js @@ -245,7 +245,6 @@ var inner_select = function(new_root_nodes, new_selected_nodes) // no change return; } - get_main_graph_view().nodes__user_visible(new_selected_nodes); updateSelectedNodesBus(new_root_nodes, new_selected_nodes); } @@ -338,8 +337,8 @@ return { selectionChangedBus: selectionChangedBus, setup_toolbar: setup_toolbar, - __get_root_nodes: function() { return root_nodes; }, - __get_selected_nodes: function() { return selected_nodes; }, + root_nodes: function() { return root_nodes; }, + selected_nodes: function() { return selected_nodes; }, }; }); |
