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

Allow pinch trackpad gesture while cooperative gestures is enabled #4465

Conversation

tomhicks
Copy link
Contributor

What this does

Enables pinching on a trackpad to zoom the map while cooperativeGestures is enabled.

Fixes #4463

Implementation

A pinch on a trackpad is actually a wheel event but with ctrlKey: true. This change adds a new method to the CooperativeGesturesHandler called shouldPreventWheelEvent which is used internally for deciding whether to show the cooperative gestures message, and from the ScrollZoomHandler::wheel method, to determine whether or not to handle the gesture in the map.

Launch Checklist

  • Confirm your changes do not include backports from Mapbox projects (unless with compliant license) - if you are not sure about this, please ask!
  • Briefly describe the changes in this PR.
  • Link to related issues.
  • Write tests for all new functionality.
  • Add an entry to CHANGELOG.md under the ## main section.

@codecov-commenter
Copy link

codecov-commenter commented Jul 30, 2024

Codecov Report

Attention: Patch coverage is 72.72727% with 3 lines in your changes missing coverage. Please review.

Project coverage is 87.74%. Comparing base (43cbe50) to head (00971b1).
Report is 63 commits behind head on main.

Files Patch % Lines
src/ui/handler/cooperative_gestures.ts 80.00% 2 Missing ⚠️
src/ui/handler/scroll_zoom.ts 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4465   +/-   ##
=======================================
  Coverage   87.74%   87.74%           
=======================================
  Files         246      246           
  Lines       33412    33421    +9     
  Branches     2209     2196   -13     
=======================================
+ Hits        29316    29326   +10     
- Misses       3081     3082    +1     
+ Partials     1015     1013    -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tomhicks
Copy link
Contributor Author

tomhicks commented Jul 30, 2024

err, code coverage is being weird:
image

How can lines 110 and 111 be not covered yet line 113 is? That's literally impossible.

Also... how can these stats of head, patch, change make sense??

image

@HarelM
Copy link
Collaborator

HarelM commented Jul 30, 2024

There's a bug with latest node regarding code coverage unfortunately...

@HarelM
Copy link
Collaborator

HarelM commented Jul 30, 2024

Did you check the pinch on a mac as well to see that it behaves the same?

@tomhicks
Copy link
Contributor Author

Did you check the pinch on a mac as well to see that it behaves the same?

I have relied on the tests for this PR. Is there a way to easily test an embed or something while developing? Or do I need to make another codebase to test this one using npm link or something?

@HarelM
Copy link
Collaborator

HarelM commented Jul 30, 2024

npm run start and surf to the test/examples folder and into the cooperative gesture example.

@tomhicks
Copy link
Contributor Author

@HarelM I've tested this on Chrome and Firefox on my MacBook Pro. I can't test Safari because the server started via npm run start doesn't open on Safari for some reason. Wonder if you've seen that before?

@HarelM
Copy link
Collaborator

HarelM commented Jul 30, 2024

I never tried opening on safari to be honest...

@HarelM HarelM merged commit c00a30b into maplibre:main Jul 30, 2024
15 checks passed
@tomhicks tomhicks deleted the allow-pinch-gesture-on-trackpad-in-cooperative-gestures-mode branch July 31, 2024 10:40
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.

Allow pinch-to-zoom on trackpads with no extra keypress with cooperativeGestures enabled.
3 participants