Skip to content

[Enhancement] - Trackpad gesture events for native pan/zoom on OSX. #219

@gcr

Description

@gcr

Hii!

Background. On OSX, users are used to zooming and panning with two-finger trackpad gestures for "canvas"-style apps like blender, Affinity Designer, Photoshop, etc. Having to hold down the mouse button to pan is a pain.

The good news: these can be captured in JavaScript using gestureevent DOM events, which are supported by Chrome, Safari, and (I think) Firefox on that platform. I've implemented support for this in my own three.js-based DOOM map editor, so I'm somewhat familiar and happy to work on this if you like.

Implementation. One way to implement this could be to refactor the camera handling into multiple modes. Upon seeing the first gestureevent event, the mode would be permanently switched to trackpad mode. Platforms which don't support trackpad events would stay in the default mode (unchanged behavior).

  • Default mode: Drag events pan the camera unless a lasso/box select is active. Vertical mousewheel events zoom the camera. Horizontal mousewheel events are ignorred.
  • Trackpad mode: Mousewheel events pan the camera vertically or horizontally. Native gesture pan/zoom events will either pan or zoom. Probably ignore rotation events. Drag events are ignored unless the lasso/box select is active.

I'm happy to do the work -- would you consider patches that implement this if the behavior doesn't affect other platforms?

Caveats.

  • Mobile. I'm not sure how this would affect mobile platforms. I think Safari on iOS sends vertical/horizontal wheel events on one-finger tap-and-drag and gestureevents on zooming, but I'd need to test. Does regl-scatterplot care about mobile?
  • Lasso. I don't see this affecting wit lasso or selection tools, am I wrong...?
  • Changed defaults. I'm proposing changing the default to be platform dependent: Windows and Linux users would have to click-and-drag, but Mac users wouldn't. The docs would get a bit more complex.
  • Downstream libraries. Do you have a sense for how this would affect library users? (I dearly want this interaction for jupyter-scatterplot for example, which is the reason why I'm starting here upstream)

Please give me some direction and then I'll start prototyping if my executive function doesn't crap itself :-)

Related: #204

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions