Skip to content

feat(editor): add zoom direction preference for mouse input#7732

Merged
kostyafarber merged 10 commits intomainfrom
kostya/scroll-direction-preference-clean
Jan 22, 2026
Merged

feat(editor): add zoom direction preference for mouse input#7732
kostyafarber merged 10 commits intomainfrom
kostya/scroll-direction-preference-clean

Conversation

@kostyafarber
Copy link
Copy Markdown
Contributor

@kostyafarber kostyafarber commented Jan 22, 2026

This PR adds a new user preference to invert mouse wheel zoom direction. Some users prefer "natural" scrolling behavior where scrolling down zooms out (like on macOS trackpads), but this conflicts with traditional mouse wheel zoom behavior.

This is a clean reimplementation of the original branch kostya/scroll-direction-preference with a narrative-quality commit history.

closes #6164

Change type

  • feature

Test plan

  1. Open the editor
  2. Go to Menu → Preferences → Input device
  3. Select "Mouse" as your input device
  4. Enable "Invert mouse zoom"
  5. Use the scroll wheel to zoom - direction should now be inverted
  6. Disable the option - zoom should return to normal
  7. Change input device to "Auto" - the invert option should appear disabled
  • Unit tests

Release notes

  • Add option to invert mouse wheel zoom direction under Preferences → Input device
  • Rename "Input mode" menu to "Input device" for clarity

API changes

  • Added isZoomDirectionInverted to TLUserPreferences interface
  • Added UserPreferencesManager.getIsZoomDirectionInverted() method
  • Added ToggleInvertZoomItem component export from @tldraw/tldraw
  • Added toggle-invert-zoom action and event

Note

Introduces a mouse-only preference to invert wheel zoom and wires it end‑to‑end across editor, storage, and UI.

  • Adds isZoomDirectionInverted to TLUserPreferences; DB migration + sync SQL and schema/types updated
  • Editor zoom logic respects inversion only when inputMode === 'mouse'; exposes getIsZoomDirectionInverted()
  • UI: new ToggleInvertZoomItem under Preferences → menu.input-device (renamed from menu.input-mode); action/event toggle-invert-zoom; translations updated across locales
  • Exports ToggleInvertZoomItem from @tldraw/tldraw; API reports regenerated; tests added for preferences and zoom behavior
  • Minor UI: button CSS honors [data-disabled] alongside :disabled

Written by Cursor Bugbot for commit 2929950. This will update automatically on new commits. Configure here.

Add a new user preference to control whether mouse wheel zoom direction
should be inverted. This preference allows users who prefer different
scrolling behavior (e.g., "natural" scrolling on Mac) to invert the zoom
direction when using a mouse.

- Add isZoomDirectionInverted to TLUserPreferences interface
- Add validation and migration support
- Add getter method to UserPreferencesManager
- Default value is false (standard zoom behavior)
Apply the zoom direction inversion preference when the user is using
mouse input mode. The inversion only takes effect when:
1. The user has enabled isZoomDirectionInverted preference
2. The user has explicitly set their input mode to 'mouse'

This ensures trackpad users are not affected and the behavior change
only applies when the user has made a deliberate choice about their
input device.
Add a new action and menu item to toggle the zoom direction inversion
preference. The toggle:
- Appears in the Input Device menu (under Preferences)
- Is disabled when input mode is not set to 'mouse'
- Includes proper translations and event tracking
- Is exported for use by consumers of the tldraw package
Update button CSS selectors to also match elements with the
data-disabled attribute. This is needed for menu items that should
appear disabled (like the invert zoom option when not in mouse mode)
but cannot use the native disabled attribute because they're still
interactive for accessibility purposes.
Rename the "Input mode" submenu to "Input device" for clarity since
it now contains both the input device selection and the zoom direction
inversion option. Also reorder submenus in preferences to place
Input device after Accessibility.
Add the zoom direction preference to the dotcom user schema and
include a database migration to add the column to the user table.
This allows the preference to be synced across devices for
logged-in users.
Update test fixtures and regenerate the fetchEverythingSql snapshot
to include the new isZoomDirectionInverted column in the user table.
Add comprehensive test coverage for the new isZoomDirectionInverted
user preference:

- Update TLUserPreferences consistency tests to include new field
- Add UserPreferencesManager tests for getIsZoomDirectionInverted
- Add camera zoom tests verifying inversion behavior:
  - Inverts zoom when mouse mode + preference enabled
  - Does NOT invert when input mode is auto (null)
  - Zooms normally when mouse mode + preference disabled
Update all translation files to use 'menu.input-device' key instead
of 'menu.input-mode', and add new toggle-invert-zoom translation keys
to main.json.
@huppy-bot huppy-bot bot closed this Jan 22, 2026
@huppy-bot
Copy link
Copy Markdown
Contributor

huppy-bot bot commented Jan 22, 2026

Sorry @kostyafarber, we're not accepting pull requests from external contributors at this time. See discussion here. If you'd like to report a bug or suggest a feature, please open an issue instead.

@vercel
Copy link
Copy Markdown

vercel bot commented Jan 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
examples Ready Ready Preview Jan 22, 2026 4:11pm
5 Skipped Deployments
Project Deployment Review Updated (UTC)
analytics Ignored Ignored Preview Jan 22, 2026 4:11pm
chat-template Ignored Ignored Preview Jan 22, 2026 4:11pm
tldraw-docs Ignored Ignored Preview Jan 22, 2026 4:11pm
tldraw-shader Ignored Ignored Preview Jan 22, 2026 4:11pm
workflow-template Ignored Ignored Preview Jan 22, 2026 4:11pm

Request Review

@kostyafarber kostyafarber reopened this Jan 22, 2026
@huppy-bot huppy-bot bot added the feature New feature label Jan 22, 2026
@kostyafarber
Copy link
Copy Markdown
Contributor Author

jammed with @steveruizok on this, landing this (clean pr) in favour of #7552

@kostyafarber kostyafarber added this pull request to the merge queue Jan 22, 2026
Merged via the queue into main with commit 7c74a71 Jan 22, 2026
15 checks passed
@kostyafarber kostyafarber deleted the kostya/scroll-direction-preference-clean branch January 22, 2026 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add scroll wheel zoom direction preference

1 participant