Skip to content

Commit

Permalink
fix(pointer): check PointerCoords.x in isDifferentPointerPosition (
Browse files Browse the repository at this point in the history
  • Loading branch information
jdufresne authored Jan 15, 2025
1 parent 8528972 commit 75edef5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/system/pointer/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function isDifferentPointerPosition(
) {
return (
positionA.target !== positionB.target ||
positionA.coords?.x !== positionB.coords?.y ||
positionA.coords?.x !== positionB.coords?.x ||
positionA.coords?.y !== positionB.coords?.y ||
positionA.caret?.node !== positionB.caret?.node ||
positionA.caret?.offset !== positionB.caret?.offset
Expand Down
21 changes: 21 additions & 0 deletions tests/pointer/move.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,24 @@ test('declare pointer coordinates', async () => {
expect(getEvents('mouseover')[0]).toHaveProperty(prop, value)
})
})

test('move pointer by x/y coords', async () => {
const {elements, getEventSnapshot, user} = setup('<div></div>')

await user.pointer([
{keys: '[MouseLeft>]', target: elements[0], coords: {x: 20, y: 20}},
{coords: {x: 40, y: 20}},
{coords: {x: 40, y: 40}},
])

expect(getEventSnapshot()).toMatchInlineSnapshot(`
Events fired on: div
div - pointerdown
div - mousedown: primary
div - pointermove
div - mousemove
div - pointermove
div - mousemove
`)
})

0 comments on commit 75edef5

Please sign in to comment.