d3 / d3-transition

Animated transitions for D3 selections.
https://d3js.org/d3-transition
ISC License
223 stars 65 forks source link

transition.easeVarying? #107

Closed mbostock closed 4 years ago

mbostock commented 4 years ago

Re-reading https://github.com/d3/d3-ease/issues/13 four years later, I feel this problem was made much more difficult by the desire to overload transition.ease to support both a single easing function shared by all selected nodes and multiple easing functions varying across nodes.

While it would be more verbose (and arguably inconsistent), an easy way around this problem is a separate transition method for the rare case where varying easing functions are desired. For example:

transition.easeVarying(d => d3.easePolyIn.exponent(d.exponent))

Unlike transition.ease, transition.easeVarying would always take a function, and it would always invoke that function for each selected node. If you pass in something that’s not a function (not a function that returns a function, in this case), it would error (though perhaps not immediately).