A drawer component for React.
Add closeTreshold prop
emilkowalski32d80aa0a67a
diff --git a/README.md b/README.mdindex f36255d..68ddd90 100644--- a/README.md+++ b/README.md@@ -49,6 +49,7 @@ Can be controlled with the `value` and `onOpenChange` props. Can be opened by deAdditional props:`fixedHeight`: Height won't be auto adjusted when the `visualViewportHeight` changes.+`closeTreshold`: Number between 0 and 1 that determines when the drawer should be closed. Example: `closeTreshold`` of 0.5 would close the drawer if the user swiped for 50% of the height of the draewr or more.### Triggerdiff --git a/src/index.tsx b/src/index.tsxindex 3c4d17c..7c9f3c1 100644--- a/src/index.tsx+++ b/src/index.tsx@@ -8,6 +8,8 @@ import './style.css';import { usePreventScroll } from './use-prevent-scroll';import { useComposedRefs } from './use-composed-refs';+const CLOSE_TRESHOLD = 0.75;+const TRANSITIONS = {DURATION: 0.5,EASE: [0.32, 0.72, 0, 1],@@ -61,6 +63,7 @@ interface DialogProps {children?: React.ReactNode;open?: boolean;defaultOpen?: boolean;+ closeTreshold?: number;onOpenChange?(open: boolean): void;shouldScaleBackground?: boolean;dismissible?: boolean;@@ -74,6 +77,7 @@ function Root({children,shouldScaleBackground,fixedHeight,+ closeTreshold = CLOSE_TRESHOLD,dismissible = true,}: DialogProps) {const [isOpen = false, setIsOpen] = useControllableState({@@ -328,7 +332,7 @@ function Root({return;}- if (y > window.innerHeight * 0.75) {+ if (y > window.innerHeight * closeTreshold) {closeDrawer();return;}