Skip to content

Commit

Permalink
Tweak gestures, add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Dec 10, 2024
1 parent 418f83d commit d7fc542
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/view/shell/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,25 @@ function ShellInner() {
renderDrawerContent={renderDrawerContent}
drawerStyle={{width: Math.min(400, winDim.width * 0.8)}}
configureGestureHandler={handler => {
if (!swipeEnabled) {
if (swipeEnabled) {
if (isDrawerOpen) {
// You probably want to close it so activate on smallest pans.
return handler.activeOffsetX([-1, 1])
} else {
// Disambiguate the drawer swipe from the pager swipe.
return (
handler
// Any finger movement to the right activates it
.activeOffsetX(1)
// Any finger movement to the left insta-fails it
.failOffsetX(-1)
)
}
} else {
// Fail the gesture immediately.
// This seems more reliable than the `swipeEnabled` prop.
// With `swipeEnabled` alone, the gesture may freeze after toggling off/on.
return handler.failOffsetX([0, 0]).failOffsetY([0, 0])
} else if (!isDrawerOpen) {
return handler.activeOffsetX(1).failOffsetX(-1)
} else {
return handler
}
}}
open={isDrawerOpen}
Expand Down

0 comments on commit d7fc542

Please sign in to comment.