An opinionated toast component for React.
Fix top position swipe direction (#513)
Hunter Martin8a8fad1fae4c
diff --git a/src/index.tsx b/src/index.tsxindex fca6d4f..a3ea512 100644--- a/src/index.tsx+++ b/src/index.tsx@@ -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 ? (