Skip to content

Feat(Canvas): Add canvas zoom on Ctrl/Cmd+MMB drag.#8965

Open
DustyShoe wants to merge 3 commits intoinvoke-ai:mainfrom
DustyShoe:Feat(Canvas)/Add-Ctrl-or-Cmd+MMB-drag-for-quick-canvas-zoom-
Open

Feat(Canvas): Add canvas zoom on Ctrl/Cmd+MMB drag.#8965
DustyShoe wants to merge 3 commits intoinvoke-ai:mainfrom
DustyShoe:Feat(Canvas)/Add-Ctrl-or-Cmd+MMB-drag-for-quick-canvas-zoom-

Conversation

@DustyShoe
Copy link
Copy Markdown
Collaborator

Summary

This PR improves canvas UX for graphics tablet users by adding support for the widely used Ctrl/Cmd+MMB zoom gesture.

  • Added canvas zoom on Ctrl/Cmd+MMB.
  • Zoom uses continuous scaling without snap points.
  • Zoom is anchored to the cursor position at drag start.
  • Added custom cursor.

QA Instructions

  1. Open the canvas and use Ctrl/Cmd+MMB drag; verify vertical drag zooms in and out.
  2. Verify the zoom is smooth and does not snap to preset zoom levels.
  3. Start zooming over a visible detail and verify the zoom stays anchored around the initial cursor position.
  4. Release MMB and verify zoom mode exits cleanly.
  5. Switch focus away during the gesture and verify zoom mode is cancelled cleanly.
  6. Verify the custom zoom cursor is shown during Ctrl/Cmd+MMB drag.

Merge Plan

Checklist

  • The PR has a short but descriptive title, suitable for a changelog
  • Tests added / updated (if applicable)
  • ❗Changes to a redux slice have a corresponding migration
  • Documentation added / updated (if applicable)
  • Updated What's New copy (if doing a release after this PR)

@github-actions github-actions Bot added the frontend PRs that change frontend files label Mar 15, 2026
@Pfannkuchensack Pfannkuchensack self-assigned this Apr 6, 2026
@Pfannkuchensack
Copy link
Copy Markdown
Collaborator

Pfannkuchensack commented Apr 20, 2026

Main concern: The removal of the ctrlKey inversion in onStageMouseWheel likely breaks trackpad pinch-to-zoom. Browsers dispatch wheel events with ctrlKey: true for pinch gestures — that was the explicit reason for the old inversion. Now those events are ignored by the stage handler and consumed by the tool module as brush/eraser resize instead. This should be clarified with the author before merge; it's not mentioned in the PR description and looks unintentional.

Everything else (zoom math, cursor SVG, fallback behavior, snap-state interaction) checks out.
I dont have a Tablet so cant really test it on that.

@DustyShoe
Copy link
Copy Markdown
Collaborator Author

@Pfannkuchensack

Thanks for calling this out. I checked the existing wheel handling more closely: the stage handler was already returning early on ctrl/meta-modified wheel events before this PR, so the old ctrlKey inversion path was dead code. The line I removed was just a small cleanup while I was already touching nearby canvas zoom code, not an intentional behavior change.

So this PR does not newly break trackpad pinch-to-zoom. That said, your broader observation is valid: ctrl/meta-modified wheel events are currently routed to brush/eraser size adjustment in the tool module, which means trackpad pinch-to-zoom does not appear to be supported today. That seems to be pre-existing behavior and is out of scope for this change.

I can revert that cleanup from this PR if we want to keep the change set strictly focused on Ctrl/Cmd+MMB zoom.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend PRs that change frontend files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants