Skip to content

Commit be423b8

Browse files
author
Robert Jackson
committed
Force updated positions upon expand/collapse.
1 parent cc81177 commit be423b8

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

app/components/basic-tree.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ export default Ember.Component.extend({
7676
return a.parent == b.parent ? 4 : 8;
7777
})
7878
.nodeSize([6, 180]);
79-
graph(root);
8079

8180
function update(source) {
81+
graph(root);
8282
let nodes = root.descendants();
8383
let links = root.links();
8484
let node = g
@@ -144,6 +144,12 @@ export default Ember.Component.extend({
144144
return `self: ${(d.data.stats.time.self / 1000000).toFixed(2)}`;
145145
});
146146

147+
// update exiting node locations
148+
node
149+
.transition()
150+
.duration(DURATION)
151+
.attr('transform', d => `translate(${d.y},${d.x})`);
152+
147153
// Transition exiting nodes to the parent's new position.
148154
node
149155
.exit()
@@ -169,6 +175,17 @@ export default Ember.Component.extend({
169175
+ " " + d.source.y + "," + d.source.x;
170176
});
171177

178+
link
179+
.transition()
180+
.duration(DURATION)
181+
.attr("d", function(d) {
182+
return "M" + d.target.y + "," + d.target.x
183+
+ "C" + (d.source.y + 50) + "," + d.target.x
184+
+ " " + (d.source.y + 50) + "," + d.source.x
185+
+ " " + d.source.y + "," + d.source.x;
186+
});
187+
188+
// update exiting link locations
172189
link
173190
.exit()
174191
.transition()

0 commit comments

Comments
 (0)