Adding a method to stack transitions in objects with several parts #149
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
This PR adds a call named stackTransition that enables composite shapes (like a pie chart or a stacked bar in a bar chart) have a coherent transition.
This solution allows to use any easing function (d3 or custom), and the composite object will transition, as a whole, the same way a simple one would, giving a smooth feeling to the overall animation.
Stacking.transitions._.Carlos.Vazquez._.Observable.mp4
How
stackTransition sets the delay, duration and easeVarying of each component inside the composite element.
They all start the transition at the same time as the overall figure (same delay) and take the same time for the transition (same duration).
The ease of each element varies, however, in such a way that
t
becomes 0 before their time to start, and 1 when they finished. All elements have the easing parameter (t) bound to [0, 1], except the first, which is open on the left (can go below 0) and the last, which is open on the right (can go above 1), in order to allow for any easing that goes beyond 0 or 1 at any point (like elastic easing)Example
https://observablehq.com/@carlos-vazquez/stacking-transitions