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

middle click #189

Closed
paolobenve opened this issue Oct 28, 2017 · 11 comments
Closed

middle click #189

paolobenve opened this issue Oct 28, 2017 · 11 comments

Comments

@paolobenve
Copy link

with modern mice middle click is performed through the central wheel.

However, apparently the plugin converts all wheel events to a delta, i.e. a wheel turn.

How do I detect a simple click?

@dmethvin
Copy link
Member

This is a StackOverflow question not related to the plugin.

@paolobenve
Copy link
Author

why is not related to the plugin? without the plugin the middle click event has type click, with the plugin has type mousewheel and (apparently) there is not any way to differentiate a middle click from a wheel turn

@mgol
Copy link
Member

mgol commented Oct 28, 2017

Clicking via the wheel should trigger a click event, not a wheel one in the same way as clicking on a regular third button on any other mouse.

Do you have a concrete example where that’s not the case?

@paolobenve
Copy link
Author

paolobenve commented Oct 30, 2017

I have in my code something like:

("#selector").on('contextmenu click mousewheel', function(ev, delta) {
  console.log(ev.type);
  ....
});

clicking in selector with left or right button, ev.type==click, with middle button ev.type==mousewheel

I'm seeing that the plugin replace type click with mousewheel, and no track of original type is left.

A solution could be to save all the changed elements in an array, naming it "originals", or something similar. This way the code could manage the middle click.

@mgol
Copy link
Member

mgol commented Oct 31, 2017

As you can see, there's no mention of click in the source of this plugin. I'd guess there must be something else going on in your code.

As a general rule, if you think there's a bug please prepare a minimal (!) jsFiddle or JSBin example so that we can quickly run it without needing to set anything up manually. Otherwise it's really hard for us to spend time on the issue, especially that often there's no bug but we can't see that before we see a test case which we would have to take time to create by ourselves.

@paolobenve
Copy link
Author

no mention of click, but at line 103:

event.type = 'mousewheel';

overwrites event.type, whose value is 'click' before that line

@mgol
Copy link
Member

mgol commented Oct 31, 2017

We still don’t have a test case, though.

@dmethvin
Copy link
Member

If the data you seek exists at all, it will be in event or in event.originalEvent. That is what the browser provides to us. Use StackOverflow to see how to detect a middle click and then see if the properties you want are there.

@paolobenve
Copy link
Author

https://jsfiddle.net/paolobenve/dkwnmc88/19/ you can see all the effects of mouse wheel on the event:

  • rotating: deltaX -> 0, deltaY -> 1/-1
  • clicking: deltaY -> 0, deltaX -> 1/-1
  • clicking aside (my mouse permits it): deltaY -> 0, deltaX -> 1/-1

checking deltaX/Y permits to detect a rotation, but not to decide wheter a click or a left/right click has been issued

@paolobenve
Copy link
Author

@dmethvin, event.originalEvent hasn't anything significative

@dmethvin
Copy link
Member

If it's not in the event the plugin receives then the plugin cannot provide the information.

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

No branches or pull requests

3 participants