Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pointer): make sure to check all fields of coords in isDifferentPointerPosition() #1229

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/system/pointer/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ export function isDifferentPointerPosition(
positionA.target !== positionB.target ||
positionA.coords?.x !== positionB.coords?.y ||
positionA.coords?.y !== positionB.coords?.y ||
positionA.coords?.clientX !== positionB.coords?.clientX ||
positionA.coords?.clientY !== positionB.coords?.clientY ||
positionA.coords?.offsetX !== positionB.coords?.offsetX ||
positionA.coords?.offsetY !== positionB.coords?.offsetY ||
positionA.coords?.pageX !== positionB.coords?.pageX ||
positionA.coords?.pageY !== positionB.coords?.pageY ||
positionA.coords?.screenX !== positionB.coords?.screenX ||
positionA.coords?.screenY !== positionB.coords?.screenY ||
positionA.caret?.node !== positionB.caret?.node ||
positionA.caret?.offset !== positionB.caret?.offset
)
Expand Down
21 changes: 21 additions & 0 deletions tests/pointer/drag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,27 @@ test('drag sequence', async () => {
`)
})

test('drag sequence w/ differing client coordinates', async () => {
const {element, getClickEventsSnapshot, user} = setup(`<div></div>`)

await user.pointer([
{keys: '[MouseLeft>]', target: element, coords: {clientX: 0, clientY: 0}},
{target: element, coords: {clientX: 0, clientY: 0}}, // doesn't actually move, won't show up in snapshot below
{target: element, coords: {clientX: 10, clientY: 0}}, // will show up in snapshot below
'[/MouseLeft]',
])

expect(getClickEventsSnapshot()).toMatchInlineSnapshot(`
pointerdown - pointerId=1; pointerType=mouse; isPrimary=true
mousedown - button=0; buttons=1; detail=1
pointermove - pointerId=1; pointerType=mouse; isPrimary=true
mousemove - button=0; buttons=1; detail=0
pointerup - pointerId=1; pointerType=mouse; isPrimary=true
mouseup - button=0; buttons=0; detail=1
click - button=0; buttons=0; detail=1
`)
})

test('drag touch', async () => {
const {element, getClickEventsSnapshot, user} = setup(`<div></div>`)

Expand Down