diff options
| author | Alon Levy <alon@pobox.com> | 2015-02-05 12:12:43 +0200 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2015-02-05 12:57:48 +0200 |
| commit | 2735e709c40215156390193a4a73f550b5e78a15 (patch) | |
| tree | cb5ed67701dee78e4c6085fefc0c2f7589e017f8 /src/client/view/graph_view.js | |
| parent | f8de41f3f0658b8d39f236daf7978c204ee92223 (diff) | |
client/graph_view: merge zoom and relayout events to redraw bus
Note that using 'on' overwrites the previous callback, using namespaces
('zoom.graph_view') doesn't help. So store the previous callback (the
zoom function in rz_core in this case) and apply it.
Diffstat (limited to 'src/client/view/graph_view.js')
| -rw-r--r-- | src/client/view/graph_view.js | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/client/view/graph_view.js b/src/client/view/graph_view.js index 1ead49aa..6347da28 100644 --- a/src/client/view/graph_view.js +++ b/src/client/view/graph_view.js @@ -691,13 +691,25 @@ function GraphView(spec) { .on("drag", dragged) .on("dragend", dragended); + var redrawBus = new Bacon.Bus(); + redrawBus.onValue(tick); + var pushRedraw = function() { redrawBus.push(null); }; + + if (spec.parent_graph_zoom_obj) { + var existing_zoom_cb = spec.parent_graph_zoom_obj.on('zoom'); + spec.parent_graph_zoom_obj.on('zoom', function () { + existing_zoom_cb.apply(null, arguments); + pushRedraw(null); + }) + } + function init_force_layout() { force = d3.layout.force() .distance(120) .gravity(0.12) .charge(-1800) .size([w, h]) - .on("tick", tick) + .on("tick", pushRedraw) .start(); } |
