Repository navigation
Press P to switch left-drag between rotate and pan - #448
Merged
Merged
Conversation
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
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Pin 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 wherePdoesn't work.How: omovi only listens for
mousedownon the canvas and has no API to remap buttons. While pan mode is on,src/utils/leftDragPan.tsstops 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. ThePshortcut sits inSimulation.tsxunder the sameapp.liveViewportVisiblegate as Space andc(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 afterP, that Shift+click selection still works in pan mode, and thatPswitches back.Known limitation: on a finished "view structure" run the viewport isn't the live view, so
Pdoes nothing there, same as Space andctoday.Closes #79
🤖 Generated with Claude Code
https://claude.ai/code/session_01HB39E3Y4jpon2ijSXT7emN