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

Reimplement camera gestures #230

Open
sargunv opened this issue Jan 4, 2025 · 2 comments
Open

Reimplement camera gestures #230

sargunv opened this issue Jan 4, 2025 · 2 comments
Labels
enhancement New feature or change to an existing feature

Comments

@sargunv
Copy link
Owner

sargunv commented Jan 4, 2025

Once we integrate with the native core, we'll lose SDK gestures on iOS, Android, and Desktop. Once we set zIndex to a negative value on web (to support Compose overlays), we'll lose SDK gestures there too.

We should reimplement gestures in Compose with pointerInput. #216 has a draft implementation of this, with pan, zoom, and rotate. This issue serves as a place to note requirements for the real version we'll build after #218. It's the ideal goal; unsure how much will be possible in Compose.

  • (Multi) touch screens
    • Single finger drag pan
    • Two finger pinch zoom
    • Two finger rotation
    • Two finger "shove" tilt
    • Double tap and release animated zoom in
    • Double tap and drag "quick" zoom in and out
  • Multi-touch trackpads
    • Two finger "scroll" pan
      • if disabled, vertical scroll should work the same as mouse scroll (zoom)
    • Two finger pinch zoom
    • Two finger rotation
  • Mouse and keyboard
    • Click and drag pan
    • Double click animated zoom in
    • Scroll zoom in and out
    • Cmd/Ctrl +/- zoom in and out
    • Secondary click and drag rotate (x) and tilt (y)
    • Shift click and drag zoom
    • Option/Alt click and drag rotate (x) and tilt (y)
  • Zoom and rotate should operate around the centroid of the touch inputs (affecting offset appropriately)
  • Pan, zoom, rotate, and tilt should have some fling velocity, with non-pan motion decaying much faster than pan
  • All gestures should be supported on all platforms (if possible), as desktop may have touch screens, mobile may be connected to a mouse and keyboard, and browsers exist on both
  • Decay, keyboard keys, active state of each gesture, and direction of quick zoom should be configurable

cc @westnordost did I miss anything?

@sargunv sargunv added the enhancement New feature or change to an existing feature label Jan 4, 2025
@westnordost
Copy link
Collaborator

westnordost commented Jan 5, 2025

Regarding keyboard:

Usually one can...

  • move the view with
  • rotate the view withShift +
  • tilt the view with Shift +
  • zoom the view with +-

Ctrl is usually only necessary for move and zoom when the map is embedded as an iframe within a website, i.e. more generally, if it is within a scrollable area.

Regarding mouse:

For right-mouse-button or Shift + mouse button, there is no expected standard behavior: Holding the right-mouse-button sometimes is used to rotate + tilt. But on maps that show a context menu on right-mouse-button click, the right mouse button usually has no gesture function. Instead, Shift + left-mouse-button is rotate + tilt.

For both MapBox and MapLibre it is possible to select an area with Shift + left-mouse-button in which the view should zoom into.

Ctrl is usually necessary for any mouse gesture when the map is embedded as an iframe within a website, i.e. more generally, if it is within a scrollable area.

@sargunv
Copy link
Owner Author

sargunv commented Jan 7, 2025

move the view with ←↑↓→
rotate the view withShift + ←→
tilt the view with Shift + ↑↓
zoom the view with +-

sgtm. for keyboard-only controls, we should probably consider focus.

Ctrl is usually only necessary for move and zoom when the map is embedded as an iframe within a website, i.e. more generally, if it is within a scrollable area.

we probably don't need to handle this, beyond making it easy to configure in our public API.

For right-mouse-button or Shift + mouse button, there is no expected standard behavior: Holding the right-mouse-button sometimes is used to rotate + tilt. But on maps that show a context menu on right-mouse-button click, the right mouse button usually has no gesture function. Instead, Shift + left-mouse-button is rotate + tilt.

Investigating other maps:

  • Apple Maps (macOS)
    • Option + left mouse drag is rotate and tilt
    • Right click is a context menu
  • Google Maps (Chrome)
    • Option + left mouse drag is rotate and tilt
    • Shift + left mouse drag is rotate and tilt
    • Control + left mouse drag is rotate and tilt
    • Right click is a context menu
  • Mapbox (Chrome)
    • Right mouse drag is rotate and tilt
    • Control + left mouse drag is rotate and tilt
    • Shift + left mouse drag is select a view to zoom in to

I think I like the Mapbox defaults, but configuration API should allow for Google/Apple-like behavior

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or change to an existing feature
Projects
None yet
Development

No branches or pull requests

2 participants