Fix panning isolation

* panning values were reused on when visiting a topology for the first
  time

Fixes #1238
This commit is contained in:
David Kaltschmidt
2016-04-18 14:23:10 +01:00
committed by Tom Wilkie
parent 8c4f025fa4
commit 4810bbc572
+3 -2
View File
@@ -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]);