Skip to content

Remove animationDuration option#451

Merged
kurkle merged 2 commits intochartjs:masterfrom
jledentu:remove-animation-duration
Apr 15, 2021
Merged

Remove animationDuration option#451
kurkle merged 2 commits intochartjs:masterfrom
jledentu:remove-animation-duration

Conversation

@jledentu
Copy link
Copy Markdown
Collaborator

@jledentu jledentu commented Apr 14, 2021

As explained in #450, I suggest to remove the animationDuration option (not working with Chart.js 3) in favor of configuration of the zoom transition.

Closes #450

Copy link
Copy Markdown
Member

@kurkle kurkle left a comment

Choose a reason for hiding this comment

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

Looks like good direction to me!

src/plugin.js Outdated
};
}
chart.update('zoom');
if (transitionMode && chart.options.transitions[transitionMode]) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it could be just chart.update('zoom'). Not sure where we'd need to use another transition mode for it?

Copy link
Copy Markdown
Collaborator Author

@jledentu jledentu Apr 15, 2021

Choose a reason for hiding this comment

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

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');
}

?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I updated the PR

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

@kurkle kurkle added the bug label Apr 14, 2021
@kurkle kurkle merged commit c38805b into chartjs:master Apr 15, 2021
@jledentu jledentu deleted the remove-animation-duration branch April 15, 2021 09:01
@kurkle kurkle added this to the 1.0.0 milestone Apr 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

animationDuration doesn't correctly define the duration of drag animation

2 participants