Remove animationDuration option#451
Conversation
kurkle
left a comment
There was a problem hiding this comment.
Looks like good direction to me!
src/plugin.js
Outdated
| }; | ||
| } | ||
| chart.update('zoom'); | ||
| if (transitionMode && chart.options.transitions[transitionMode]) { |
There was a problem hiding this comment.
I think it could be just chart.update('zoom'). Not sure where we'd need to use another transition mode for it?
There was a problem hiding this comment.
Yeah, I had left the door open to more customization in other zoom modes, but maybe unnecessary. I can just leave a useTransition parameter in the doZoom function:
if (useTransition && chart.options.transitions.zoom) {
chart.update('zoom');
}?
There was a problem hiding this comment.
I don't think we need to check if the transition is configured, it will fall back to default animations if not. And we need to update in either case. Also feels like the useTransition is not needed, because one can configure the zoom transition to have no duration.
There was a problem hiding this comment.
Ok I agree for the chart.options.transitions.zoom check. But we need a useTransition parameter because there are some calls to doZoom where we don't want any animation. For instance when zooming with mouse scroll, using an animation creates a "latency" which is very annoying.
There was a problem hiding this comment.
Good point, sheds some light to your thinking of possibly needing separate transitions too.
It could be ideal if we could provide some additional info in the context of the transition:
options: {
transitions: {
zoom: {
animation: {
duration: ctx => ctx.mode === 'scroll' || ctx.mode === 'reset' : 0 ? 500
}
}
}
}But as we can't we need to separate by transition.
So eventually we might have zoomScroll, zoomDrag, zoomReset, pan transitions?
Back to this PR, I think useTransition is good enough for this bug fix.
As explained in #450, I suggest to remove the
animationDurationoption (not working with Chart.js 3) in favor of configuration of thezoomtransition.Closes #450