Skip to content

Commit

Permalink
Cancel current drag when closing the drawer (#263)
Browse files Browse the repository at this point in the history
  • Loading branch information
henriqemalheiros authored Feb 9, 2024
1 parent f1810ba commit b75b703
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,8 @@ function Root({
function closeDrawer() {
if (!drawerRef.current) return;

cancelDrag();

onClose?.();
set(drawerRef.current, {
transform: isVertical(direction)
Expand Down Expand Up @@ -492,6 +494,15 @@ function Root({
}
}

function cancelDrag() {
if (!isDragging || !drawerRef.current) return;

drawerRef.current.classList.remove(DRAG_CLASS);
isAllowedToDrag.current = false;
setIsDragging(false);
dragEndTime.current = new Date();
}

function onRelease(event: React.PointerEvent<HTMLDivElement>) {
if (!isDragging || !drawerRef.current) return;

Expand Down

0 comments on commit b75b703

Please sign in to comment.