Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/graphConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,12 @@ export type TGraphConstants = {
*/
PINCH_ZOOM_SPEED: number;
/**
* Multiplier for camera pan speed applied to both mouse drag and trackpad swipe gestures.
* Does not affect auto-panning (see AUTO_PAN_SPEED) or zoom speed (see SPEED, PINCH_ZOOM_SPEED).
* Multiplier for camera pan speed applied to trackpad two-finger swipe (and
* mouse-wheel scroll when MOUSE_WHEEL_BEHAVIOR is "scroll"). Pointer drag
* (mouse drag and single-finger trackpad drag) tracks the cursor 1:1 and
* is not affected — applying a multiplier there would slide the canvas
* out from under the cursor. Does not affect auto-panning (see AUTO_PAN_SPEED)
* or zoom speed (see SPEED, PINCH_ZOOM_SPEED).
*
* @default 1
*/
Expand Down
9 changes: 4 additions & 5 deletions src/services/camera/Camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,10 @@ export class Camera extends EventedComponent<TCameraProps, TComponentState, TGra
if (!this.lastDragEvent) {
return;
}
const panSpeed = this.context.constants.camera.PAN_SPEED;
this.camera.move(
(event.pageX - this.lastDragEvent.pageX) * panSpeed,
(event.pageY - this.lastDragEvent.pageY) * panSpeed
);
// No PAN_SPEED multiplier here: pointer drag tracks the cursor 1:1, otherwise
// the canvas slides out from under the pointer. PAN_SPEED only scales
// wheel-delta-driven trackpad swipes (see handleTrackpadMove).
this.camera.move(event.pageX - this.lastDragEvent.pageX, event.pageY - this.lastDragEvent.pageY);
this.lastDragEvent = event;
}

Expand Down
Loading