Skip to content

feat: adding trackpad mode#222

Open
Chuwee wants to merge 1 commit intostan-smith:masterfrom
Chuwee:feature/add-trackpad-mode
Open

feat: adding trackpad mode#222
Chuwee wants to merge 1 commit intostan-smith:masterfrom
Chuwee:feature/add-trackpad-mode

Conversation

@Chuwee
Copy link
Copy Markdown

@Chuwee Chuwee commented Feb 4, 2026

I decided to attempt to solve the issue

#220

I implemented a little trackpad mode which takes care of the problem (Settings -> Zoom)

Here's a video

Grabacion.de.pantalla.2026-02-04.a.las.11.30.06.mov

@Chuwee Chuwee force-pushed the feature/add-trackpad-mode branch from 0afa60f to bdc1809 Compare February 4, 2026 10:16
@Chuwee Chuwee force-pushed the feature/add-trackpad-mode branch from bdc1809 to f59690d Compare February 4, 2026 10:20
@Chuwee Chuwee changed the title Feature/add trackpad mode feat: adding trackpad mode Feb 4, 2026
@stan-smith
Copy link
Copy Markdown
Owner

Hi 👋

Thanks for the contribution. I've recently tightened up the contribution guidelines for FossFLOW, including enforcing Conventional Commits for PR titles.

Your PR title doesn't follow the required format:

<type>(<scope>): <subject>

Valid types: feat, fix, perf, refactor, docs, style, test, chore, build, ci

Examples:

  • feat: add undo/redo functionality
  • fix: prevent menu from opening during drag
  • docs: update installation instructions

I'm closing this PR. If your changes are still relevant, please:

  1. Read the updated CONTRIBUTING.md
  2. Resubmit with a compliant PR title
  3. Make sure you fill in the PR template

Cheers,
Stan

@stan-smith stan-smith closed this Feb 5, 2026
@stan-smith stan-smith reopened this Feb 5, 2026
@stan-smith
Copy link
Copy Markdown
Owner

^^ apologies @Chuwee this got caught up in my purge.
Looks great! Ill have a look.
Stan

@stan-smith
Copy link
Copy Markdown
Owner

Hi @Chuwee I've been moving house, so I've been really busy.
I promise I havent forgotten!

@Chuwee
Copy link
Copy Markdown
Author

Chuwee commented Mar 10, 2026

@stan-smith no worries! take your time

@Chuwee
Copy link
Copy Markdown
Author

Chuwee commented Mar 30, 2026

@stan-smith yo?

@stan-smith
Copy link
Copy Markdown
Owner

@Chuwee Im so sorry, I am just swamped at the moment, I'll try to give it a look today

Copy link
Copy Markdown
Owner

@stan-smith stan-smith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few things to sort before this can go in:

Bug: stale closure on uiState
On master, onScroll reads fresh state every invocation:
tsconst onScroll = (e: WheelEvent) => {
const uiState = uiStateApi.getState();
// ...

Your version captures uiState.zoomSettings.trackpadMode from the outer closure, so if someone toggles trackpad mode in settings it won't actually take effect until the effect re-runs. Call uiStateApi.getState() at the top of onScroll and you're sorted.
Perf: passive: false applied unconditionally
diff- uiState.rendererEl?.addEventListener('wheel', onScroll, { passive: true });

  • uiState.rendererEl?.addEventListener('wheel', onScroll, { passive: false });
    This blocks the compositor thread on every wheel event for everyone, regardless of whether trackpad mode is on. preventDefault() is only relevant in trackpad mode, so passive should be conditional on the current setting — you'll need to tear down and re-register the listener when it changes.
    Code duplication

The zoom-to-cursor maths (~30 lines) is copy-pasted across both the trackpad-pinch and mouse-mode branches. Pull it out into a shared helper:
tsconst applyZoom = (e: WheelEvent, oldZoom: number, newZoom: number, uiState: ...) => {
if (uiState.zoomSettings.zoomToCursor && rendererRef.current && rendererSize) {
// zoom-to-cursor maths...
} else {
uiState.actions.setZoom(newZoom);
}
};

Both branches just call applyZoom(e, oldZoom, newZoom, uiState) and you're done.

Nitpicks:
const panSpeed = 1.0 — multiplying by 1.0 is a no-op. Either drop it or make it a configurable setting.

Please rebase on current master (1.10.8) so we don't get the stale package-lock.json version diff.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you rebase to 1.10.8 please

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.

2 participants