-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
d3.interpolateTransformSvg returning an empty string #68
Comments
Isn’t the empty string equivalent to |
The problem is just lack of consistency. The interpolator should return the target value for
...into this:
Thus, in the next iteration, a code that tries to get the current transform value for calculating the next one will break. |
That’s not how d3.interpolateTransformSvg works; it decomposes the given transformation into a standard representation, and then interpolates that. So, it’s not guaranteed that the interpolated value at t = 1 is string-equal to the target value a, just that the two will be equivalent transforms. This property is true of many of D3’s interpolators. For example, When you say “a code that tries to get the current transform value for calculating the next one will break”, what do you mean? d3.interpolateTransformSvg seems to work fine when interpolating from the empty string to a non-empty transform: d3.interpolateTransformSvg("", "translate(100, 0)")(0.5) // "translate(50, 0)" |
I meant a code that uses Anyway, now I see this is by design. Thanks for your explanation, as always it was very useful. |
Thank you for your patience. I’ll close, but I’ll also mention that I would like to change how interpolateTransform works in #44, such that we interpolate transform function lists (when the start and end transform have the same structure) rather than matrices. I think that would also address your needs here: since But implementing this is non-trivial so I haven’t yet found time to do it. Contributions welcome! |
Context: I'm using a transition for changing the
"translate"
transform function of some elements. Sometimes the position doesn't change, so the transition goes fromfoo
to the samefoo
.However, I've notice that when transitioning from
"translate(0,0)"
to"translate(0,0)"
the interpolator returns an empty string. The interpolator in question isd3.interpolateTransformSvg
.For instance:
But:
Here is a basic demo: https://jsfiddle.net/bvudenyq/
I'm not sure if the issue is in
d3.interpolateTransformSvg
itself or in the parse.js file. The solution is quite simple, in my case I'm just usingattrTween
withd3.interpolateString
as the interpolator, ditchingd3.interpolateTransformSvg
, but I thought I should mention this bug.Thanks,
The text was updated successfully, but these errors were encountered: