3 ms·
One of the coolest things about this gist is how little code is used for the animation; basically just these lines: d3.selectAll(nodes).transition()
by couchand 12y ago
One of the coolest things about this gist is how little code is used for the animation; basically just these lines:
d3.selectAll(nodes).transition()
.duration(2500)
.delay(function() { return this.depth * 50; })
.ease("quad-in-out")
.tween("position", function() {
var d = this, i = d3.interpolate([d[0], d[1]], [d.y, d.x]);
return function(t) { var p = i(t); d.t = t; d[0] = p[0]; d[1] = p[1]; };
});
The tree layout auto-magically gives every node a depth property, we delay the transition by an amount proportional to the depth, and then over the course of two-and-a-half seconds tween the line segment into the new position. Simple and effective. The hard part is generating the maze.