fix(editor): one press is either a pan or a click
useFraming takes an optional panning gate read on each one-pointer move; the editor passes the press machine's drag-with-pan phase, so a zoomed pen within its 6 px slop or a mouse wiggle no longer pans and clicks. Catalogue: no options, behaviour unchanged. Test added: « a press is either a pan or a click, never both (R-8) » (pen 5 px clicks without pan, pen 8 px pans without click, mouse wiggle clicks without pan). No assertion removed.
This commit is contained in:
1 parent
35e4a4c75a
commit
b2d78f9621
4 files changed
+83
-21
No files matched your search
@@ -1092,13 +1092,11 @@ describe('« Désélectionner » (R1, A6)', () => {
|
||||
}),
|
||||
})
|
||||
const panel = await selectFromList()
|
||||
await userEvent
|
||||
.setup()
|
||||
.click(
|
||||
within(panel).getByRole('button', {
|
||||
name: 'Remplacer par un polygone',
|
||||
}),
|
||||
)
|
||||
await userEvent.setup().click(
|
||||
within(panel).getByRole('button', {
|
||||
name: 'Remplacer par un polygone',
|
||||
}),
|
||||
)
|
||||
const open = await screen.findByTestId('annotation-properties')
|
||||
expect(
|
||||
within(open).queryByRole('button', { name: 'Désélectionner' }),
|
||||
@@ -1461,6 +1459,55 @@ describe('a tap on the drawing (D6b)', () => {
|
||||
expect(marker('anno-b')).not.toHaveAttribute('data-state')
|
||||
})
|
||||
|
||||
it('a press is either a pan or a click, never both (R-8)', async () => {
|
||||
await selected()
|
||||
vi.spyOn(box(), 'getBoundingClientRect').mockReturnValue({
|
||||
...{ x: 0, y: 0, left: 0, top: 0, right: 400, bottom: 300 },
|
||||
...{ width: 400, height: 300, toJSON: () => ({}) },
|
||||
})
|
||||
await userEvent
|
||||
.setup()
|
||||
.click(screen.getByRole('button', { name: 'Zoom avant' }))
|
||||
const transform = () => drawing().parentElement!.style.transform
|
||||
/** A press at (10, 10) moved through the given x offsets, released at the last. */
|
||||
const press = (type: string, path: number[]) => {
|
||||
fireEvent.pointerDown(rect(), {
|
||||
...init(1, type),
|
||||
clientX: 10,
|
||||
clientY: 10,
|
||||
})
|
||||
for (const dx of path) {
|
||||
fireEvent.pointerMove(rect(), {
|
||||
...init(1, type),
|
||||
clientX: 10 + dx,
|
||||
clientY: 10,
|
||||
})
|
||||
}
|
||||
const last = 10 + (path.at(-1) ?? 0)
|
||||
fireEvent.pointerUp(rect(), {
|
||||
...init(1, type),
|
||||
clientX: last,
|
||||
clientY: 10,
|
||||
})
|
||||
}
|
||||
const zoomed = transform()
|
||||
expect(zoomed).toContain('scale(1.5)')
|
||||
// A pen within its 6 px slop: a click (it deselects), no pan.
|
||||
press('pen', [5])
|
||||
expect(transform()).toBe(zoomed)
|
||||
expect(isDeselected()).toBe(true)
|
||||
// A pen past its slop: a pan, no click.
|
||||
await selectFromList()
|
||||
press('pen', [4, 8])
|
||||
expect(transform()).not.toBe(zoomed)
|
||||
expect(isDeselected()).toBe(false)
|
||||
// A mouse wiggling 14 px of path, never 4 px away from the press: a click, no pan.
|
||||
const panned = transform()
|
||||
press('mouse', [3, -3, 2])
|
||||
expect(transform()).toBe(panned)
|
||||
expect(isDeselected()).toBe(true)
|
||||
})
|
||||
|
||||
it('a finger drags the selected point (its handle), never a selected zone (A13)', async () => {
|
||||
const zone = zoneAnnotation({ type: 'polygon', points: triangle })
|
||||
await selected({
|
||||
|
||||
Reference in new issue
Block a user