History

Fail the header drawer pan at touch-down outside the header strip

The drawer gesture's 40px-wide left-edge hitSlop spans the full screen height; its y-position check only ran in onEnd, after the pan had already activated and stolen the touch from the native back-swipe recognizer. Fail the gesture immediately when the touch starts below the header so left-edge back-swipes work everywhere else.

Theo Browne committed 4 months ago

Commit 90ea2d31 parent 9ac1d7f1 file · +10 −0Browse files

Unified · Split

apps/mobile/src/features/threads/ThreadDetailScreen.tsx+10−0
@@ -276,6 +276,16 @@ export const ThreadDetailScreen = memo(function ThreadDetailScreen(props: Thread · 275 unmodified lines
276276 .hitSlop({ left: 0, width: 40 })
277277 .activeOffsetX([10, 999])
278278 .failOffsetY([-24, 24])
279+ // Fail at touch-down for anything below the header strip. Activating
280+ // there (the y check in onEnd fires too late to matter) swallows the
281+ // left-edge touch and blocks the native back-swipe along the whole
282+ // screen height.
283+ .onTouchesDown((event, stateManager) => {
284+ const touchY = event.allTouches[0]?.y ?? Number.POSITIVE_INFINITY;
285+ if (touchY >= drawerGestureThreshold) {
286+ stateManager.fail();
287+ }
288+ })
279289 .onEnd((event) => {
280290 const translationX = Math.max(event.translationX, 0);
281291 if (event.y < drawerGestureThreshold && translationX > 56) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t