I'm attempting to use the code found here as a jumping off point for a project. This code uses D3 to transition between two paths using a function called pathTween(), which is as follows:
function pathTween(d1, precision) {
return function() {
var path0 = this,
path1 = path0.cloneNode(),
n0 = path0.getTotalLength(),
n1 = (path1.setAttribute("d", d1), path1).getTotalLength();
// Uniform sampling of distance based on specified precision.
var distances = [0], i = 0, dt = precision / Math.max(n0, n1);
while ((i += dt) < 1) distances.push(i);
distances.push(1);
// Compute point-interpolators at each distance.
var points = distances.map(function(t) {
var p0 = path0.getPointAtLength(t * n0),
p1 = path1.getPointAtLength(t * n1);
return d3.interpolate([p0.x, p0.y], [p1.x, p1.y]);
});
return function(t) {
return t < 1 ? "M" + points.map(function(p) { return p(t); }).join("L") : d1;
};
};
}
What has me baffled is that in this example, something in this block of code is giving the transition an ease-in-out sort of movement, and I want to change this to linear. I think it must be a D3 default in one of the functions used within pathTween(), unless I'm overlooking the part of pathTween() that would add that easing.
Anyone have an idea of what might be defaulting to ease-in-out and how to change it?
Thanks