From 0a179c6b01c8be2677e89d159ce25dc742836555 Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Fri, 27 Feb 2015 08:13:12 +0200 Subject: client: graph_view: handle screen resize --- src/client/view/graph_view.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/client/view/graph_view.js') diff --git a/src/client/view/graph_view.js b/src/client/view/graph_view.js index 3d39c03f..d723188b 100644 --- a/src/client/view/graph_view.js +++ b/src/client/view/graph_view.js @@ -88,10 +88,10 @@ function GraphView(spec) { vis, deliverables, // FIXME - want to use parent_element - w = $(document.body).innerWidth(), - h = $(document.body).innerHeight(), - cx = w / 2, - cy = h / 2, + w, + h, + cx, + cy, // FIXME take filter names from index.html or both from graph db filter_states = {'interest':null, 'skill':null, 'club':null, 'person':null, 'third-internship-proposal':null}, filter_state_names = ['interest', 'skill', 'club', 'person', 'third-internship-proposal']; @@ -104,6 +104,17 @@ function GraphView(spec) { (temporary || svgInput !== undefined), "missing spec variable"); + function update_window_size() { + w = $(document.body).innerWidth(); + h = $(document.body).innerHeight(); + cx = w / 2; + cy = h / 2; + } + + // update view whenever screen is resized + $(window).asEventStream('resize').map(update_window_size).onValue(function () { update_view(false); }); + update_window_size(); + function read_checkboxes() { var checkboxes = $('#menu__type-filter label input').map( function (i, checkbox){ -- cgit v1.3.1