From 4810bbc572c5eb29605c5073b7a204b0e6ff107b Mon Sep 17 00:00:00 2001 From: David Kaltschmidt Date: Mon, 18 Apr 2016 14:06:43 +0200 Subject: [PATCH] Fix panning isolation * panning values were reused on when visiting a topology for the first time Fixes #1238 --- client/app/scripts/charts/nodes-chart.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/app/scripts/charts/nodes-chart.js b/client/app/scripts/charts/nodes-chart.js index f7ec690eb..df4a5f887 100644 --- a/client/app/scripts/charts/nodes-chart.js +++ b/client/app/scripts/charts/nodes-chart.js @@ -63,8 +63,9 @@ export default class NodesChart extends React.Component { // wipe node states when showing different topology if (nextProps.topologyId !== this.props.topologyId) { - // re-apply cached canvas zoom/pan to d3 behavior - const nextZoom = this.state.zoomCache[nextProps.topologyId]; + // re-apply cached canvas zoom/pan to d3 behavior (or set defaul values) + const defaultZoom = { scale: 1, panTranslateX: 0, panTranslateY: 0, hasZoomed: false }; + const nextZoom = this.state.zoomCache[nextProps.topologyId] || defaultZoom; if (nextZoom) { this.zoom.scale(nextZoom.scale); this.zoom.translate([nextZoom.panTranslateX, nextZoom.panTranslateY]);