-
Notifications
You must be signed in to change notification settings - Fork 331
Added optional modifier keys #382
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
Conversation
7929626
to
7681b14
Compare
I think a better way to handle this might be a generic function that let's you filter whether the zoom occurs as proposed in #329. That would allow you to handle more use cases Or maybe you can actually handle this case already today with an external listener that enables the plugin when the modifier key is pressed and disables the plugin when the modifier key is released and all we need is an example of doing that |
Okay, why the heck do you delete comments? |
The comments are meant for code review. If you want to express interest you can simply leave a thumbs up on the PR |
@BarryPSmith would you be up to rebasing this? |
@benmccann I think that this and #329 are intended to solve different problems. I do not see any parameters in that PR related to keys or the type of input that is causing the zoom or pan event.
Perhaps I overestimate the complexity of the situation. I would be interested to see the robust example. @kurkle Is there interest in merging this then? What else needs to be done for this to be merged? |
@BarryPSmith yes, I think something like this is needed. I'm not sure there is a use case for the non-mouse modifier, that we meght want to leave out - unless there is a use case. Maybe some nits, I did not do a full review yet. |
It looks like enough has changed that it'll be easier to rewrite the PR. That's the impression I get looking at the conflict files that rebase has generated. At least it's a fairly simple set of changes to the functional code. I'll throw away the zoom tests, given the modified test/utils.js has migrated into a different repo. At least the weather is bad here so I have time. |
d5cb18f
to
1bd830a
Compare
some lint issues, |
1bd830a
to
d88e9a0
Compare
Test coverage decrease: In order to test the new code one must be able to send mouse events with keys attached. That is not possible with the current test framework - util.js of chartjs-test-utils must be updated. See test/util.js of d5cb18f |
Ok, I'll take a look at the tests later. I think it needs to be a WheelEvent for the delta stuff. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good. I'm not sure about the event names, is there some reasoning that I missed?
Thanks @BarryPSmith |
Often the chart captures scroll events in an undesired way, so this PR makes it possible to set an optional
wheelModifierKey
that must be pressed to activate mouse wheel zoom.A
modifierKey
can also be set for pan. By default this is only checked when the input comes via mouse, but can be set for touch and other inputs withrequireModifierNonMouse: true
zoom.onWheelModifierKeyFailed
is fired when a zoom does not occur because the modifier key is not present (e.g. to allow the consumer to display "Press ctrl to zoom"). A similarpan.onModifierKeyFailed
is also available.Although not necessarily the requested fix, it will help with the following issues:
#377, #370, #335, #308 (Actually I see the collaborators offer to accept PRs on this issue there). Not looking any further...
Relationship to other pull requests:
Might be incompatible with #380.
A more flexible version of #368