-
-
Notifications
You must be signed in to change notification settings - Fork 757
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
Enable Multi-MouseButton Support for dragPan #5354
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5354 +/- ##
==========================================
- Coverage 91.84% 91.83% -0.02%
==========================================
Files 282 282
Lines 38908 38930 +22
Branches 6827 6831 +4
==========================================
+ Hits 35735 35750 +15
- Misses 3046 3052 +6
- Partials 127 128 +1 ☔ View full report in Codecov by Sentry. |
How will this behave when rotating with right click (default behavior) and setting drag pan to right click? |
@@ -58,7 +62,7 @@ export class MouseMoveStateManager implements DragMoveStateManager<MouseEvent> { | |||
} | |||
|
|||
isValidStartEvent(e: MouseEvent) { | |||
return this._correctEvent(e); | |||
return this._correctEvent(e, this._buttons); |
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.
Instead of passing buttons it might be better to pass a predicate to override the default one - what happens if someone wants to have right click with control button for panning?
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.
Good to point that out! I've tried setting the right click for panning and it looks like if dragRotate is enabled it will not pan the map. So it is safe for now?.
I would gladly accept any help with a better approach since I'm not good with typescript and have not much experience in large projects in general.
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.
_correctEvent is basically what you want to override.
I would try and find a way to pass it down instead if adding a buttons parameter and pass that down...
This PR enhances the functionality of dragPan in MapLibre GL JS, addressing feature request #5341.
It introduces the ability to configure one or multiple mouse buttons for the dragPan interaction using the MouseEvent.button property.
Previously, dragPan was limited to left mouse button, restricting user interaction and personalization. This improvement provides greater flexibility for users who want to customize the drag behavior of the map.
Examples
1. Configuring on Map Initialization:
2. Updating on DragPan Enable:
Launch Checklist
CHANGELOG.md
under the## main
section.