diff --git a/src/index.tsx b/src/index.tsx index 24ee3f2..15255f0 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -365,7 +365,7 @@ const Toast = (props: ToastProps) => { const swipeDirections = props.swipeDirections ?? getDefaultSwipeDirections(position); // Determine swipe direction if not already locked - if (!swipeDirection && (Math.abs(xDelta) > 5 || Math.abs(yDelta) > 5)) { + if (!swipeDirection && (Math.abs(xDelta) > 1 || Math.abs(yDelta) > 1)) { setSwipeDirection(Math.abs(xDelta) > Math.abs(yDelta) ? 'x' : 'y'); } diff --git a/test/tests/basic.spec.ts b/test/tests/basic.spec.ts index bb2d695..019f400 100644 --- a/test/tests/basic.spec.ts +++ b/test/tests/basic.spec.ts @@ -112,12 +112,18 @@ test.describe('Basic functionality', () => { const dragBoundingBox = await toast.boundingBox(); if (!dragBoundingBox) return; - await page.mouse.move(dragBoundingBox.x + dragBoundingBox.width / 2, dragBoundingBox.y); + // Initial touch point + await page.mouse.move(dragBoundingBox.x + dragBoundingBox.width / 2, dragBoundingBox.y); await page.mouse.down(); - await page.mouse.move(0, dragBoundingBox.y + 300); + // Move mouse slightly to determine swipe direction + await page.mouse.move(dragBoundingBox.x + dragBoundingBox.width / 2, dragBoundingBox.y + 10); + + // Complete the swipe + await page.mouse.move(0, dragBoundingBox.y + 300); await page.mouse.up(); + await expect(page.getByTestId('dismiss-el')).toHaveCount(1); });