Skip to content

Press P to switch left-drag between rotate and pan - #448

Merged
andeplane merged 4 commits into
mainfrom
claude/issue-79-pan-shortcut
Oct 16, 2026
Merged

andeplane merged 4 commits into
mainfrom
claude/issue-79-pan-shortcut

Conversation

@andeplane

@andeplane andeplane commented Oct 16, 2026 •

Copy link
Copy Markdown
Owner

Requested by Anders Hafreager · project thread

Before: in the 3D view, left-drag always rotated and right-drag was the only way to pan, so trackpad users and people whose browser or extensions take over the right button couldn't pan.

After: pressing P in the live run viewport switches left-drag between rotate and pan. In pan mode a small "Pan mode · press P to rotate" label shows in the bottom-left and the cursor becomes a move cursor. Right-drag still pans in both modes, and click and Shift+click atom selection work as before. Leaving the live viewport turns pan mode off, so it can't get stuck on a screen where P doesn't work.

How: omovi only listens for mousedown on the canvas and has no API to remap buttons. While pan mode is on, src/utils/leftDragPan.ts stops a left-button mousedown in the capture phase and re-dispatches it as a right-button mousedown with the same coordinates and modifiers, so nothing in omovi changes. Pan mode lives in the render store and isn't persisted. The P shortcut sits in Simulation.tsx under the same app.liveViewportVisible gate as Space and c (ignored in inputs or with Ctrl/Meta/Alt), and a sibling effect resets pan mode when that gate closes. Unit tests cover the remap, store, shortcut and reset; a new e2e spec (e2e/pan-mode.spec.ts, not part of the smoke suite because it imports the store) checks that left-drag rotates by default, pans after P, that Shift+click selection still works in pan mode, and that P switches back.

Known limitation: on a finished "view structure" run the viewport isn't the live view, so P does nothing there, same as Space and c today.

Closes #79

🤖 Generated with Claude Code

https://claude.ai/code/session_01HB39E3Y4jpon2ijSXT7emN

Trackpad users and browsers with right-button gestures had no way to pan
the 3D view. Pressing P in the viewport now toggles pan mode: left-drag
pans the camera, a small "Pan mode" label appears in the bottom-left of
the view, and the cursor changes to a move cursor. Right-drag still pans
in both modes.

omovi hardcodes left=rotate/right=pan with no remap API, so while pan
mode is on a left-button mousedown on the canvas is stopped in the
capture phase and re-dispatched as a right-button mousedown. Clicks and
Shift+click selection keep working because the picker reads only the
position and Shift state.

Closes #79

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HB39E3Y4jpon2ijSXT7emN
@andeplane andeplane self-assigned this Oct 16, 2026
@andeplane
andeplane marked this pull request as ready for review October 16, 2026 07:08
Brings the P pan-mode shortcut (#79) up to date with main's refactors.

Conflict resolution:
- src/components/Simulation.tsx: kept main's shortcut handler (gated on
  app.liveViewportVisible, hook-based notify, visualizer from the
  EngineRegistry) and added the panMode/setPanMode selectors; the P
  toggle sits under the same gate as Space and c.
- src/components/Simulation.test.tsx: kept main's mocks and tests and
  added setPanMode plus the P toggle test.
- src/containers/View.tsx: took main's version (EngineRegistry-backed
  particles/bonds/visualizer, box/wall overlays moved to
  useSimulationBoxOverlays) and re-added the panMode selector, the
  remapLeftDragToPan effect and the leftDragPan import.
- src/store/render.ts, render.test.ts: main moved visualizer/particles/
  bonds out of the render store; panMode and setPanMode stay there (not
  persisted) with their test.

Follow-ups for main's new structure:
- src/containers/View.test.tsx: the mocked store now carries
  render.panMode, since View reads it.
- e2e/pan-mode.spec.ts: read the visualizer from the exported
  EngineRegistry (engine.visualizer) instead of store render state.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HB39E3Y4jpon2ijSXT7emN
P only toggles pan mode while the live viewport is visible, but View
applied the left-drag remap and label regardless. Pan mode turned on in
a live run therefore stayed active on a finished view-only run's 3D
view, where P can't switch it off. Reset panMode when
app.liveViewportVisible goes false.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HB39E3Y4jpon2ijSXT7emN
Resolved the View.tsx import conflict by keeping both the pan remap and
the scale bar imports.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HB39E3Y4jpon2ijSXT7emN
@andeplane
andeplane merged commit 7a07354 into main Oct 16, 2026
3 checks passed
@andeplane
andeplane deleted the claude/issue-79-pan-shortcut branch October 16, 2026 14:02
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.

Add a keyboard shortcut to switch the mouse between rotate and pan

2 participants