fix(editor): loupe copy without ids, two fingers counted in the pinch

Minor 1: the loupe's copy of the drawing drops every id (the equine
drawing has 142); its url(#…) and href="#…" resolve to the originals.
Minor 2: useFraming's onPinch marks the two-finger flag at the pinch
move itself; the passive effect that read the live press phase and
the press hook's multi() are removed.
This commit is contained in:
bchanot committed 2026-11-18 11:17:42 +01:00
1 parent 181f81789a
commit dd3f245bca
5 files changed
+59 -33

No files matched your search

@@ -1,11 +1,4 @@
import {
useEffect,
useRef,
type CSSProperties,
type KeyboardEvent,
type PointerEvent,
} from 'react'
import type { Framing as Frame } from '@/catalogue/framing'
import type { CSSProperties, KeyboardEvent, PointerEvent } from 'react'
import { useFraming } from '@/catalogue/useFraming'
import type { ToolId } from './uiState'
import { usePressGesture, type PressInput } from './usePressGesture'
@@ -58,24 +51,6 @@ function touchStyle(
return { touchAction: none ? 'none' : 'pan-x pan-y' }
}
const sameFrame = (a: Frame, b: Frame) =>
a.scale === b.scale && a.x === b.x && a.y === b.y
/**
* R-1: a framing that changed while two pointers or more were down is a two-finger pan or
* zoom that worked; the editor visit then never shows the two-finger hint again.
*/
function useTwoFingersWorked(framing: Frame, multi: () => boolean): void {
const last = useRef(framing)
const isMulti = useRef(multi)
isMulti.current = multi
useEffect(() => {
const changed = !sameFrame(last.current, framing)
last.current = framing
if (changed && isMulti.current()) markTwoFingers()
}, [framing])
}
/**
* Everything the canvas box listens to: zoom and pan, the press machine (click, drag,
* tap), and the keys. Keys only count when the box itself is the target: Enter on
@@ -89,8 +64,9 @@ export function useCanvasGestures(input: GestureInput) {
// press is either a pan or a click, never both (R-8).
panning: () => input.tool === 'select' && press.panning(),
twoPointerPan: true,
// R-1: a two-finger pan or zoom that worked; the visit never shows the hint again.
onPinch: markTwoFingers,
})
useTwoFingersWorked(framing.framing, press.multi)
const onKeyDown = (event: KeyboardEvent) => {
if (event.target !== event.currentTarget) return
framing.handlers.onKeyDown(event)
@@ -369,8 +369,6 @@ export function usePressGesture(input: PressInput) {
return {
preview: drag.preview,
finger: drag.finger,
/** Two pointers or more are down: a pan or zoom of the fingers, never a click. */
multi: () => machine.current.press.phase === 'multi',
panning: () => {
const press = machine.current.press
return press.phase === 'drag' && press.action.type === 'pan'