Skip to content

Commit

Permalink
fixing problem described in issue #34
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu Poignet committed Jan 19, 2012
1 parent b795a83 commit 0d4cf16
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 84 deletions.
20 changes: 14 additions & 6 deletions src/main/resources/webapp/js/jit.js
Expand Up @@ -14984,8 +14984,9 @@ TM.Base = {
Sets the parent node of the current selected node as root.
*/
out: function(){
if(this.busy) return;
out: function(node){

if(this.busy && !node) return;
this.busy = true;
this.events.hoveredNode = false;
var that = this,
Expand All @@ -14997,6 +14998,7 @@ TM.Base = {
clickedNode = parent,
previousClickedNode = this.clickedNode;


//if no parents return
if(!parent) {
this.busy = false;
Expand All @@ -15009,9 +15011,14 @@ TM.Base = {
if(config.request) {
that.requestNodes(parent, {
onComplete: function() {
that.compute();
that.plot();
that.busy = false;
if(node && clickedNode!=node){
that.out(node);
that.busy = false;
}else{
that.compute();
that.plot();
that.busy = false;
}
}
});
} else {
Expand All @@ -15025,7 +15032,8 @@ TM.Base = {
if (config.levelsToShow > 0)
this.geom.setRightLevelToShow(parent);
//animate node positions
if(config.animate) {
if((config.animate && !node) || (config.animate && clickedNode==node)) {
console.log("animate");
this.clickedNode = clickedNode;
this.compute('end');
//animate the visible subtree only
Expand Down
79 changes: 1 addition & 78 deletions src/main/resources/webapp/js/treemap.js
Expand Up @@ -33,85 +33,8 @@ var JsonB;

function goToNode(nodeId) {
var node = tm.graph.getNode(nodeId);

if (tm.busy)
return;
tm.busy = true;
tm.events.hoveredNode = false;
if (nodeId == tm.root) {
var that = tm,
config = tm.config,
graph = tm.graph,
parents = node.getParents(),
parent = node,
clickedNode = node,
previousClickedNode = tm.clickedNode;
} else {
var that = tm,
config = tm.config,
graph = tm.graph,
parents = node.getParents(),
parent = parents[0],
clickedNode = parent,
previousClickedNode = tm.clickedNode;
}

// final plot callback
callback = {
onComplete : function() {
that.clickedNode = parent;
if (config.request) {
that.requestNodes(parent, {
onComplete : function() {
that.compute();
that.plot();
that.busy = false;
}
});
} else {
that.compute();
that.plot();
that.busy = false;
}
}
};
// prune tree
if (config.levelsToShow > 0)
tm.geom.setRightLevelToShow(parent);
// animate node positions
tm.out(node);
pushNodeName(node);
if (config.animate) {
tm.clickedNode = clickedNode;
tm.compute('end');
// animate the visible subtree only
tm.clickedNode = previousClickedNode;
tm.fx.animate({
modes : [ 'linear', 'node-property:width:height' ],
duration : 1000,
onComplete : function() {
// animate the parent subtree
that.clickedNode = clickedNode;
// change nodes alpha
graph.eachNode(function(n) {
n.setDataset([ 'current', 'end' ], {
'alpha' : [ 0, 1 ]
});
}, "ignore");
previousClickedNode.eachSubgraph(function(node) {
node.setData('alpha', 1);
}, "ignore");
that.fx.animate({
duration : 500,
modes : [ 'node-property:alpha' ],
onComplete : function() {
callback.onComplete();
}
});
}
});
} else {
callback.onComplete();
}
}
function pushNodeName(node) {
var names = "";
Expand Down

0 comments on commit 0d4cf16

Please sign in to comment.