Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/hooks/useSwipeBack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Mimics iOS back gesture for PWA/web views with visual slide animation.
*/
import { useEffect, useRef, useCallback } from "react";
import { Capacitor } from "@capacitor/core";

const EDGE_THRESHOLD = 30; // px from left edge to start
const SWIPE_MIN_DISTANCE = 100; // px to trigger back
Expand Down Expand Up @@ -30,6 +31,10 @@ export function useSwipeBack() {
}, []);

useEffect(() => {
// Only enable swipe-back on native platforms; on web the browser
// already provides its own back-swipe gesture, causing "double back".
if (!Capacitor.isNativePlatform()) return;

function onTouchStart(e: TouchEvent) {
const touch = e.touches[0];
if (touch.clientX <= EDGE_THRESHOLD) {
Expand Down