Skip to content

Commit

Permalink
Always drag side drawers (#247)
Browse files Browse the repository at this point in the history
  • Loading branch information
emilkowalski authored Feb 1, 2024
1 parent dc1e35d commit ac4ad6e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit ac4ad6e

Please sign in to comment.