From c1523863c46c42d3377b006725b2b5d6b2d92372 Mon Sep 17 00:00:00 2001 From: David Kaltschmidt Date: Wed, 16 Sep 2015 12:12:51 +0200 Subject: [PATCH] Close details on canvas click --- client/app/scripts/charts/nodes-chart.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/client/app/scripts/charts/nodes-chart.js b/client/app/scripts/charts/nodes-chart.js index 30d1b9788..318b29fbe 100644 --- a/client/app/scripts/charts/nodes-chart.js +++ b/client/app/scripts/charts/nodes-chart.js @@ -5,6 +5,7 @@ const React = require('react'); const timely = require('timely'); const Spring = require('react-motion').Spring; +const AppActions = require('../actions/app-actions'); const AppStore = require('../stores/app-store'); const Edge = require('./edge'); const Naming = require('../constants/naming'); @@ -28,7 +29,7 @@ const NodesChart = React.createClass({ return { nodes: {}, edges: {}, - nodeScale: 1, + nodeScale: d3.scale.linear(), translate: [0, 0], panTranslate: [0, 0], scale: 1, @@ -47,6 +48,7 @@ const NodesChart = React.createClass({ .on('zoom', this.zoomed); d3.select('.nodes-chart') + .on('click', this.handleBackgroundClick) .call(this.zoom); }, @@ -79,6 +81,7 @@ const NodesChart = React.createClass({ // undoing .call(zoom) d3.select('.nodes-chart') + .on('click', null) .on('mousedown.zoom', null) .on('onwheel', null) .on('onmousewheel', null) @@ -322,6 +325,10 @@ const NodesChart = React.createClass({ }; }, + handleBackgroundClick: function() { + AppActions.clickCloseDetails(); + }, + restoreLayout: function(state) { const edges = state.edges; const nodes = state.nodes; @@ -352,7 +359,7 @@ const NodesChart = React.createClass({ const expanse = Math.min(props.height, props.width); const nodeSize = expanse / 2; - const nodeScale = d3.scale.linear().range([0, nodeSize / Math.pow(n, 0.7)]); + const nodeScale = this.state.nodeScale.range([0, nodeSize / Math.pow(n, 0.7)]); const timedLayouter = timely(NodesLayout.doLayout); const graph = timedLayouter(