Skip to content

fix(camera): don't apply PAN_SPEED to pointer drag#295

Merged
Antamansid merged 1 commit intomainfrom
fix_pointer_drag_speed
Apr 29, 2026
Merged

fix(camera): don't apply PAN_SPEED to pointer drag#295
Antamansid merged 1 commit intomainfrom
fix_pointer_drag_speed

Conversation

@Antamansid
Copy link
Copy Markdown
Collaborator

@Antamansid Antamansid commented Apr 29, 2026

Problem

PAN_SPEED was applied to both the wheel-driven trackpad swipe (handleTrackpadMove) and the pointer drag (onDragUpdate). Pointer drag covers two cases:

  1. Mouse: pressing left button on empty canvas and dragging.
  2. Trackpad: single-finger press-and-drag (the OS converts it to a regular pointer drag, not a wheel event).

In both cases the delta passed to camera.move() is the literal cursor displacement (event.pageX - lastDragEvent.pageX). Multiplying it by PAN_SPEED > 1 makes the canvas slide out from under the pointer — the cursor and the grabbed point stop tracking 1:1.

Two-finger trackpad swipes go through wheel events with abstract deltaX/deltaY units, so a multiplier there is meaningful and stays.

Fix

  • Camera.onDragUpdate: drop the PAN_SPEED multiplier; pointer drag now tracks the cursor 1:1 regardless of PAN_SPEED.
  • handleTrackpadMove: unchanged — still scales wheel deltas by PAN_SPEED.
  • Updated PAN_SPEED JSDoc in graphConfig.ts to reflect the new semantics (trackpad swipe / wheel scroll only, not pointer drag).

Summary by Sourcery

Ensure camera pointer drag pans the scene 1:1 with cursor movement instead of being affected by the configurable pan speed multiplier.

Bug Fixes:

  • Stop applying PAN_SPEED to pointer-based camera dragging so the grabbed point stays aligned with the cursor.

Documentation:

  • Clarify PAN_SPEED documentation to specify that it only affects wheel and two-finger trackpad swipe panning, not pointer drag.

@Antamansid Antamansid requested a review from draedful as a code owner April 29, 2026 09:00
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Apr 29, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Removes the PAN_SPEED multiplier from pointer-drag camera movement so that drag panning tracks the cursor 1:1, while keeping PAN_SPEED semantics for wheel/trackpad swipe and updating the PAN_SPEED documentation accordingly.

File-Level Changes

Change Details Files
Stop applying PAN_SPEED to pointer-drag-based camera panning and document that PAN_SPEED only affects wheel/trackpad swipe deltas.
  • In Camera.onDragUpdate, remove reading PAN_SPEED from context and call camera.move() with the raw pageX/pageY deltas so pointer drag maps 1:1 to cursor movement.
  • Add an explanatory inline comment in onDragUpdate clarifying that PAN_SPEED is intentionally not used for pointer drag and is reserved for wheel-delta-driven trackpad swipes.
  • Update the PAN_SPEED JSDoc in graphConfig.ts to specify that it only scales trackpad two-finger swipe and mouse-wheel scroll panning, not pointer drag, and clarify what it does not affect (auto-panning and zoom).
src/services/camera/Camera.ts
src/graphConfig.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@gravity-ui-bot
Copy link
Copy Markdown
Contributor

Preview is ready.

@Antamansid Antamansid merged commit a1e40d7 into main Apr 29, 2026
7 checks passed
@Antamansid Antamansid deleted the fix_pointer_drag_speed branch April 29, 2026 09:24
@gravity-ui gravity-ui Bot mentioned this pull request Apr 29, 2026
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.

3 participants