mapbox / mapbox-maps-ios

Interactive, thoroughly customizable maps for iOS powered by vector tiles and Metal
https://www.mapbox.com/mapbox-mobile-sdk
Other
485 stars 157 forks source link

Pinch gesture not recognized on trackpad #1744

Open mic12130 opened 2 years ago

mic12130 commented 2 years ago

Environment

Observed behavior and steps to reproduce

When performing a pinch gesture on a connected trackpad, there is no change on the map view, instead of the expected behavior of zooming in/out (this is what MapKit looks like).

This may affect many scenarios including iPad + Magic Trackpad, iPad + Universal Control, iPad app running on Apple Silicon Mac etc.

Expected behavior

A pinch gesture on the trackpad should be recognized and reacted as same as the one on the touch screen.

Notes / preliminary analysis

I tried to dive down a little bit into this issue and I found that it's supposed to be caused by the numberOfTouches validation in PinchGestureHandler.swift - the validation discards any input whose numberOfTouches is other than 2, while the property will always return 0 when the input is from a trackpad.

Note: I haven't found any information about numberOfTouches returning 0 in Apple's documents, but it is observed every time in my testing.

Additional links and references

raphschwander commented 6 months ago

I am experiencing the same issue. Did you find any workaround @mic12130 ?

mic12130 commented 6 months ago

Ahh it has been 2 years. I gave up fixing this as the outcome wasn't worth the works for me. Besides updating codes of the framework, an idea once in my mind was implementing a custom pinch gesture recognizer to particularly handle the trackpad case. (as the built-in recognizer just skips anything happened on trackpads) Then with the combination of the finger locations and the map's camera setter, everything should work.

snboyle16 commented 1 month ago

Hi! @mapbox-ci I have run into this issue as well, pinch gestures do not work on trackpad