Skip to content

Commit

Permalink
Merge pull request #1156 from nextstrain/improve-tree-zoom-logic
Browse files Browse the repository at this point in the history
Keep sources of the root of the zoomed-subtree in sync. Closes #1139
  • Loading branch information
jameshadfield committed Jun 9, 2020
2 parents 67a9fe3 + e288c6d commit aa9e36a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/components/tree/phyloTree/phyloTree.js
Expand Up @@ -11,7 +11,7 @@ import * as confidence from "./confidence";
import * as labels from "./labels";

/* phylogenetic tree drawing function - the actual tree is rendered by the render prototype */
const PhyloTree = function PhyloTree(reduxNodes, id) {
const PhyloTree = function PhyloTree(reduxNodes, id, idxOfInViewRootNode) {
this.grid = false;
this.attributes = ['r', 'cx', 'cy', 'id', 'class', 'd'];
this.params = createDefaultParams();
Expand Down Expand Up @@ -40,7 +40,7 @@ const PhyloTree = function PhyloTree(reduxNodes, id) {
setYValues(this.nodes);
this.xScale = scaleLinear();
this.yScale = scaleLinear();
this.zoomNode = this.nodes[0];
this.zoomNode = this.nodes[idxOfInViewRootNode];
this.strainToNode = {};
this.nodes.forEach((phylonode) => {this.strainToNode[phylonode.n.name] = phylonode;});
/* debounced functions (AFAIK you can't define these as normal prototypes as they need "this") */
Expand Down
4 changes: 2 additions & 2 deletions src/components/tree/tree.js
Expand Up @@ -44,7 +44,7 @@ class Tree extends React.Component {
setUpAndRenderTreeToo(props, newState) {
/* this.setState(newState) will be run sometime after this returns */
/* modifies newState in place */
newState.treeToo = new PhyloTree(props.treeToo.nodes, "RIGHT");
newState.treeToo = new PhyloTree(props.treeToo.nodes, "RIGHT", props.treeToo.idxOfInViewRootNode);
if (attemptUntangle) {
untangleTreeToo(newState.tree, newState.treeToo);
}
Expand All @@ -53,7 +53,7 @@ class Tree extends React.Component {
componentDidMount() {
if (this.props.tree.loaded) {
const newState = {};
newState.tree = new PhyloTree(this.props.tree.nodes, "LEFT");
newState.tree = new PhyloTree(this.props.tree.nodes, "LEFT", this.props.tree.idxOfInViewRootNode);
renderTree(this, true, newState.tree, this.props);
if (this.props.showTreeToo) {
this.setUpAndRenderTreeToo(this.props, newState); /* modifies newState in place */
Expand Down

0 comments on commit aa9e36a

Please sign in to comment.