Skip to content

Check if not a left-click, then bail out of onStart #2

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

Closed
wants to merge 1 commit into from

Conversation

AlexVvx
Copy link
Owner

@AlexVvx AlexVvx commented Oct 11, 2017

Related to #248

This PR adds check in dragElement. On start, if not a left-click, then bail out of onStart. The purpose of this check is to let developers to use their own context menu instead of browser context menu. Without that check there were no possibility to see 'contextmenu' event when click inside plot container.


var rightclick;
if(e.which) { rightclick = (e.which === 3); }
else if(e.button) { rightclick = (e.button === 2); }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah nice, I was initially thinking of testing for "not a left click" but this is better - more robust and targeted.
It doesn't look like we actually need e.which anymore - far as I can tell every browser modern enough to support SVG defines e.button.

We'll need to include a test or two of this behavior, probably in https://github.com/plotly/plotly.js/blob/master/test/jasmine/tests/dragelement_test.js - want to give that a try and PR it to the main repo?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Sure, let's do that!

@AlexVvx AlexVvx closed this Oct 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants