Skip to content

armgit / vaul

Public Imported from GitHub
0

A drawer component for React.

Always drag side drawers (#247)

Emil Kowalskiac4ad6e241d5
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 42f6a9d..0470f2d 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -788,7 +788,7 @@ packages:
resolution: {integrity: sha512-D94LjX4Sp0xJFVaoQOd3OO9k7tpBYNOXdVhkltUbGv2Qb9OXdrg/CpsjlZv7ia14Sylv398LswWBVVu5nqKzAQ==}
peerDependencies:
'@types/react': '*'
- react: ^16.8 || ^17.0 || ^18.0 || 18.2.0
+ react: ^16.8 || ^17.0 || ^18.0
peerDependenciesMeta:
'@types/react':
optional: true
diff --git a/src/index.tsx b/src/index.tsx
index 78ffd4c..9564e4d 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -159,13 +159,17 @@ function Root({
const swipeAmount = drawerRef.current ? getTranslate(drawerRef.current, direction) : null;
const date = new Date();
+ if (direction === 'right' || 'left') {
+ return true;
+ }
+
// Allow scrolling when animating
if (openTime.current && date.getTime() - openTime.current.getTime() < 500) {
return false;
}
if (swipeAmount !== null) {
- if (direction === 'bottom' || direction === 'right' ? swipeAmount > 0 : swipeAmount < 0) {
+ if (direction === 'bottom' ? swipeAmount > 0 : swipeAmount < 0) {
return true;
}
}
@@ -486,10 +490,7 @@ function Root({
function onRelease(event: React.PointerEvent<HTMLDivElement>) {
if (!isDragging || !drawerRef.current) return;
- // if (isAllowedToDrag.current && isInput(event.target as HTMLElement)) {
- // // If we were just dragging, prevent focusing on inputs etc. on release
- // (event.target as HTMLInputElement).blur();
- // }
+
drawerRef.current.classList.remove(DRAG_CLASS);
isAllowedToDrag.current = false;
setIsDragging(false);