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
Add interpolateZoom.rho. Fixes #25. #61
Conversation
src/zoom.js
Outdated
} | ||
|
||
i.duration = S * 1000; | ||
zoom.rho = function(_) { | ||
var _1 = +_, _2 = _1 * _1, _4 = _2 * _2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var _1 = +_, _2 = _1 * _1, _4 = _2 * _2; | |
var _1 = Math.max(1e-3, +_), _2 = _1 * _1, _4 = _2 * _2; |
It tends to crash when rho < 1e-3, at which point we could switch to a linear interpolator; but more simply this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would also be more consistent with the usual APIs if we returned the current rho when arguments.length === 0
src/zoom.js
Outdated
} | ||
|
||
i.duration = S * 1000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't work with smaller values for rho (the duration becomes infinite); the movement should be faster when curvature is low, and slower for higher curvature.
… of a linear transform)
…should be longer when the curvature is important
I think we're done. We can remove the getter if you're not happy with it. |
This should not be a getter because it’s not mutating the interpolator—it’s returning a new interpolator. The precedent here is other interpolation and easing parameters, such as: https://github.com/d3/d3-interpolate#interpolate_gamma |
(For context, see also d3/d3-ease#13.) |
No description provided.