-
Notifications
You must be signed in to change notification settings - Fork 10
Description
Hi,
I'm experimenting with this amazing library and I wanted to talk about some features that I would like to be present.
Most of them concern transitions.
1. Different transition durations per attributes
Let's imagine that we wish the width to change in 100ms and the height in 1000ms (maybe allow this behaviour with delay but that may be too much)
const datum = {
append: "rect",
- width: {enter: 100, exit: 0},
+ width: {enter: 100, exit: 0, duration: 100},
height: 100,
duration: 1000 // default duration
};
2. Pass transition object instead of duration, delay and ease.
I found myself using the same values in different components, which boils down to something like
const t = {duration: 250, delay: 10, ease: d3.easeQuadInOut};
// later
const ExampleComponent = (c) => ({
append: "g",
// ...
...t,
...c
})I feel that it could be more esthetic to directly pass a d3.transition object
const transition = d3.transition()
.duration(250)
.delay(10)
.ease(d3.easeQuadInOut);
// or
// const transition = {duration: 250, delay: 10, ease: d3.easeQuadInOut};
// ...later
const ExampleComponent = (c) => ({
append: "g",
// ...
transition,
...c
})Which might also allow for transition chaining shenanigans.
3. Datum components
When using d3-render, I cannot interact the with the component I have currently selected:
const $svg = d3.create('svg')
.attr('width', "100")
.attr('height', '100')
.attr('viewBox', [0, 0, 50, 50]);
render($svg, [/*data*/]);If I want to animate $svg's attributes, i need to use $svg.transtion()..., where something like this is waay better.
// by the power of d3-render
render(d3.create('svg'), {
width: 100,
height, 100,
viewBox: [0, 0, 50, 50],
duration: 100,
children: [/*data*/]
})4. Self controlled components
This is placed last, because it goes against the data->render flow. Because it might be an interesting case.
I wish my components had a react-like state/props approach. Where I could have some data which is passed down by data and the rest is self managed.
working example : https://observablehq.com/@stardisblue/d3-render-self-controlled-components
In this example, the components are setup using call. But call is not triggered during "update" state. So I cannot do a state/props setup (as in react for example).
This is more a defaultstate/state approach.
Conclusion
This issue might be arguably the worst issue github as ever seen, as it presents no errors to fix and proposes way too much features. I was tempted to make several issues out of this one, but that felt like spam. So here are several features that I will be more that happy to see included. I can pull request you some of them but I feel like these [propositions] need an Okay from your side.