Skip to content

Commit

Permalink
fix solo viewport panning
Browse files Browse the repository at this point in the history
  • Loading branch information
a-type committed Sep 18, 2024
1 parent 970ee34 commit e2acee0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
8 changes: 6 additions & 2 deletions src/components/canvas/CanvasGestureLayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,12 @@ function useCanvasGestures({
y: state.xy[1],
}),
);
const isQualifiedTap =
state.tap &&
(gestureInputEventRef.current.inputType === 'touch' ||
gestureInputEventRef.current.inputType === 'mouse1');
if (isObjectOrToolGestureClaim() && gestureState.claimedBy) {
if (state.tap) {
if (isQualifiedTap) {
canvas.onClaimedTap(gestureInputEventRef.current);
}
canvas.onClaimedDragEnd(gestureInputEventRef.current);
Expand All @@ -183,7 +187,7 @@ function useCanvasGestures({
if (!gestureInputEventRef.current.defaultPrevented) {
defaultOnDragEnd(gestureInputEventRef.current, canvas);
}
} else {
} else if (isQualifiedTap) {
canvas.onCanvasTap(gestureInputEventRef.current);
onTap?.(gestureInputEventRef.current, canvas);
if (!gestureInputEventRef.current.defaultPrevented) {
Expand Down
11 changes: 0 additions & 11 deletions src/components/viewport/viewportHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { useStableCallback } from '../../hooks.js';
import { Viewport } from '../../logic/Viewport.js';
import { Vector2 } from '../../types.js';
import { gestureState } from '../gestures/useGestureState.js';
import { isMiddleClick, isRightClick } from '@a-type/utils';

/**
* Tracks cursor position and sends updates to the socket connection
Expand Down Expand Up @@ -158,18 +157,8 @@ export function useViewportGestureControls(
const bindPassiveGestures = useGesture(
{
onDrag: (state) => {
// viewport drag is middle click only
if (!('button' in state.event) || !isMiddleClick(state.event)) {
return;
}

// ignore gestures claimed by objects or regions
if (gestureState.claimType) {
console.debug(
'ignoring drag claimed by',
gestureState.claimType,
gestureState.claimedBy,
);
return;
}

Expand Down

0 comments on commit e2acee0

Please sign in to comment.