Skip to content

Commit 5f3d28f

Browse files
fix(pointer): check all fields of PointerCoords in isDifferentPointerPosition() (#1229)
Co-authored-by: Bryan Jensen <[email protected]>
1 parent 75edef5 commit 5f3d28f

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/system/pointer/shared.ts

+8
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ export function isDifferentPointerPosition(
2929
positionA.target !== positionB.target ||
3030
positionA.coords?.x !== positionB.coords?.x ||
3131
positionA.coords?.y !== positionB.coords?.y ||
32+
positionA.coords?.clientX !== positionB.coords?.clientX ||
33+
positionA.coords?.clientY !== positionB.coords?.clientY ||
34+
positionA.coords?.offsetX !== positionB.coords?.offsetX ||
35+
positionA.coords?.offsetY !== positionB.coords?.offsetY ||
36+
positionA.coords?.pageX !== positionB.coords?.pageX ||
37+
positionA.coords?.pageY !== positionB.coords?.pageY ||
38+
positionA.coords?.screenX !== positionB.coords?.screenX ||
39+
positionA.coords?.screenY !== positionB.coords?.screenY ||
3240
positionA.caret?.node !== positionB.caret?.node ||
3341
positionA.caret?.offset !== positionB.caret?.offset
3442
)

tests/pointer/drag.ts

+21
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,27 @@ test('drag sequence', async () => {
2020
`)
2121
})
2222

23+
test('drag sequence w/ differing client coordinates', async () => {
24+
const {element, getClickEventsSnapshot, user} = setup(`<div></div>`)
25+
26+
await user.pointer([
27+
{keys: '[MouseLeft>]', target: element, coords: {clientX: 0, clientY: 0}},
28+
{target: element, coords: {clientX: 0, clientY: 0}}, // doesn't actually move, won't show up in snapshot below
29+
{target: element, coords: {clientX: 10, clientY: 0}}, // will show up in snapshot below
30+
'[/MouseLeft]',
31+
])
32+
33+
expect(getClickEventsSnapshot()).toMatchInlineSnapshot(`
34+
pointerdown - pointerId=1; pointerType=mouse; isPrimary=true
35+
mousedown - button=0; buttons=1; detail=1
36+
pointermove - pointerId=1; pointerType=mouse; isPrimary=true
37+
mousemove - button=0; buttons=1; detail=0
38+
pointerup - pointerId=1; pointerType=mouse; isPrimary=true
39+
mouseup - button=0; buttons=0; detail=1
40+
click - button=0; buttons=0; detail=1
41+
`)
42+
})
43+
2344
test('drag touch', async () => {
2445
const {element, getClickEventsSnapshot, user} = setup(`<div></div>`)
2546

0 commit comments

Comments
 (0)