Skip to content

armgit / vaul

Public Imported from GitHub
0

A drawer component for React.

fix: closeThreshold not working as expected when direction="left" (#385) (#386)

yodhcn51d67afa8acf
diff --git a/src/index.tsx b/src/index.tsx
index 15b0674..72af83a 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -527,8 +527,10 @@ export function Root({
}
const visibleDrawerHeight = Math.min(drawerRef.current.getBoundingClientRect().height ?? 0, window.innerHeight);
+ const visibleDrawerWidth = Math.min(drawerRef.current.getBoundingClientRect().width ?? 0, window.innerWidth);
- if (swipeAmount >= visibleDrawerHeight * closeThreshold) {
+ const isHorizontalSwipe = direction === 'left' || direction === 'right';
+ if (Math.abs(swipeAmount) >= (isHorizontalSwipe ? visibleDrawerWidth : visibleDrawerHeight) * closeThreshold) {
closeDrawer();
onReleaseProp?.(event, false);
return;