Skip to content

Commit

Permalink
Fix top position swipe direction (#513)
Browse files Browse the repository at this point in the history
  • Loading branch information
hunterrmartinn authored Nov 8, 2024
1 parent 1487e04 commit 8a8fad1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -320,15 +320,15 @@ const Toast = (props: ToastProps) => {

const yPosition = event.clientY - pointerStartRef.current.y;
const isHighlighted = window.getSelection()?.toString().length > 0;
const swipeAmount = Number(toastRef.current?.style.getPropertyValue('--swipe-amount').replace('px', '') || 0);
const swipeAmount = y === 'top' ? Math.min(0, yPosition) : Math.max(0, yPosition);

if (swipeAmount > 0) {
if (Math.abs(swipeAmount) > 0) {
setIsSwiped(true);
}

if (isHighlighted) return;

toastRef.current?.style.setProperty('--swipe-amount', `${Math.max(0, yPosition)}px`);
toastRef.current?.style.setProperty('--swipe-amount', `${swipeAmount}px`);
}}
>
{closeButton && !toast.jsx ? (
Expand Down

0 comments on commit 8a8fad1

Please sign in to comment.