Skip to content
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

Merged
merged 8 commits into from Aug 23, 2020
Merged

Add interpolateZoom.rho. Fixes #25. #61

merged 8 commits into from Aug 23, 2020

Conversation

mbostock
Copy link
Member

No description provided.

src/zoom.js Outdated
}

i.duration = S * 1000;
zoom.rho = function(_) {
var _1 = +_, _2 = _1 * _1, _4 = _2 * _2;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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?

Copy link
Member

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;
Copy link
Member

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.

@Fil
Copy link
Member

Fil commented Jun 5, 2020

I think we're done. We can remove the getter if you're not happy with it.

@mbostock
Copy link
Member Author

mbostock commented Jun 5, 2020

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
https://github.com/d3/d3-ease#back_overshoot
https://github.com/d3/d3-ease#elastic_period
https://github.com/d3/d3-ease#elastic_amplitude

@mbostock
Copy link
Member Author

mbostock commented Jun 5, 2020

(For context, see also d3/d3-ease#13.)

@Fil Fil added the feature label Jul 10, 2020
@Fil Fil mentioned this pull request Jul 10, 2020
Merged
@Fil Fil merged commit 77b7f74 into master Aug 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

None yet

2 participants