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

Fix calculation of dragDistance for click #232

Merged
merged 1 commit into from
Apr 25, 2019
Merged

Fix calculation of dragDistance for click #232

merged 1 commit into from
Apr 25, 2019

Conversation

benmccann
Copy link
Collaborator

@benmccann benmccann commented Apr 17, 2019

Closes #205

@troygibb
Copy link

@benmccann any chance this will be merged any time soon?

@benmccann
Copy link
Collaborator Author

I don't have the ability to merge it until someone reviews it

@benmccann benmccann closed this Apr 18, 2019
@benmccann benmccann reopened this Apr 18, 2019
Copy link

@seantott seantott left a comment

Choose a reason for hiding this comment

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

These changes look good to me.

@benmccann benmccann merged commit 6d7164c into master Apr 25, 2019
@simonbrunel simonbrunel deleted the issue205 branch April 26, 2019 07:20

if (directionEnabled(chartInstance.$zoom._options.zoom.mode, 'x')) {
Copy link
Member

Choose a reason for hiding this comment

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

The previous logic seems better since we avoid calculating extra values in case directionEnabled was false

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The previous logic was buggy, so hardly better :-)

I sent a follow up that's optimized better than the previous version even: #236

I don't think the change will be meaningfully different, but it doesn't hurt either, so I'm not opposed to it

Copy link
Member

Choose a reason for hiding this comment

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

Obviously, I didn't mean the whole previous logic was better :)

offsetX, startX, endX and dragDistanceX (same for the Y variants) don't need to be calculated if xEnabled (respectively yEnabled) are false (still the case in the new code).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm. dragDistanceX is used here: https://github.com/chartjs/chartjs-plugin-zoom/blob/master/src/plugin.js#L447. That parameter ends up being ignored in the case that xEnabled=false, but I'm not sure I like the idea of passing in a junk value knowing what that method will do internally. And I'd rather not spend developer time worrying about saving a couple subtraction operations which have no real cost

@ghost
Copy link

ghost commented May 1, 2019

Can you publish a new version on npm that includes this fix?
Thanks in advance

@troygibb
Copy link

troygibb commented May 6, 2019

Thanks again @benmccann for getting this in!!!

exwm pushed a commit to exwm/chartjs-plugin-zoom that referenced this pull request Apr 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Single click on legend is interpreted as drag
5 participants