Skip to content

Commit

Permalink
fix: logic error in intent detection (#407)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbismut authored Dec 6, 2021
1 parent c5267a9 commit cffaba5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/breezy-berries-serve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@use-gesture/core': patch
---

fix: logic error in intent detection
2 changes: 1 addition & 1 deletion packages/core/src/engines/Engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ export abstract class Engine<Key extends GestureKey> {
if (_step[1] === false) _step[1] = Math.abs(_m1) >= t1 && Math.sign(_m1) * t1
}

state.intentional = _step[0] !== false || _step[0] !== false
state.intentional = _step[0] !== false || _step[1] !== false

if (!state.intentional) return

Expand Down
3 changes: 2 additions & 1 deletion test/drag.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,11 @@ describe.each([
fireEvent.pointerUp(element, { pointerId: 8 })
})

test(`applying an axis SHOULDN'T start the gesture if gesture is not detected first in the right axis`, () => {
test(`applying an axis SHOULDN'T start the gesture if gesture is not detected first in the right axis`, async () => {
rerender(<Component gestures={['Drag']} config={{ drag: { axis: 'x' } }} />)
fireEvent.pointerDown(element, { pointerId: 81, clientX: 0, clientY: 0, buttons: 1 })
fireEvent.pointerMove(element, { pointerId: 81, clientX: 0, clientY: 50, buttons: 1 })
await later()
fireEvent.pointerMove(element, { pointerId: 81, clientX: 10, clientY: 0, buttons: 1 })
expect(getByTestId(`${prefix}drag-dragging`)).toHaveTextContent('false')
fireEvent.pointerUp(element, { pointerId: 81 })
Expand Down

0 comments on commit cffaba5

Please sign in to comment.