A drawer component for React.
fix closeThreshold bug (#32)
Mugeeb Hassan8336f459e90a
diff --git a/src/index.tsx b/src/index.tsxindex 787e6c3..4626d3f 100644--- a/src/index.tsx+++ b/src/index.tsx@@ -8,7 +8,7 @@ import './style.css';import { usePreventScroll, isInput } from './use-prevent-scroll';import { useComposedRefs } from './use-composed-refs';-const CLOSE_TRESHOLD = 0.75;+const CLOSE_TRESHOLD = 0.25;const SCROLL_LOCK_TIMEOUT = 1000;const TRANSITIONS = {@@ -349,10 +349,10 @@ function Root({setIsDragging(false);dragEndTime.current = new Date();const swipeAmount = drawerRef.current- ? getComputedStyle(drawerRef.current).getPropertyValue('--swipe-amount').slice(0, -2)+ ? Number.parseInt(getComputedStyle(drawerRef.current).getPropertyValue('--swipe-amount').slice(0, -2), 10): null;- if (!shouldDrag(event.target, false) || !swipeAmount) return;+ if (!shouldDrag(event.target, false) || !swipeAmount || Number.isNaN(swipeAmount)) return;if (dragStartTime.current === null) return;@@ -375,7 +375,9 @@ function Root({return;}- if (y > window.innerHeight * closeTreshold) {+ const visibleDrawerHeight = Math.min(drawerRef.current?.getBoundingClientRect().height || 0, window.innerHeight);++ if (swipeAmount >= visibleDrawerHeight * closeTreshold) {closeDrawer();onReleaseProp?.(event, false);return;