Skip to content

Expose cancellable event or API to disable browser swipe navigation (horizontal/vertical gestures) #12374

@cullsin

Description

@cullsin

What is the issue with the HTML Standard?

🚫 Feature Request: Expose Cancellable Event or API to Disable Browser Swipe Navigation Gestures

📌 Summary

Modern browsers implement native swipe gestures (horizontal and vertical) for navigation (e.g., back/forward, overscroll). However, these gestures are not exposed to web applications and cannot be intercepted using event.preventDefault().

This creates a limitation for advanced web applications that rely on custom gesture handling.


❗ Problem Statement

Currently:

  • Browser-level swipe gestures (trackpad/mobile) trigger navigation
  • No DOM event is fired for these gestures
  • event.preventDefault() cannot stop navigation
  • CSS like overscroll-behavior is insufficient or inconsistent

As a result, developers cannot:

  • Detect swipe navigation gestures
  • Override default browser behavior
  • Implement custom gesture-driven UX reliably

🎯 Expected Behavior

Web applications should be able to:

  1. Detect swipe navigation gestures
  2. Prevent default navigation when required
  3. Implement custom gesture handling

🔍 Current Behavior

  • Horizontal swipe → triggers back/forward navigation
  • Vertical overscroll → triggers browser-level actions
  • No standard event is emitted
  • No reliable opt-out mechanism exists

💥 Impact

This limitation affects:

  • Full-screen web apps (e.g., editors, dashboards)
  • PWAs and mobile-first applications
  • Canvas/WebGL-based apps
  • Gesture-heavy UI/UX systems

Issues observed:

  • Unexpected navigation → loss of application state
  • Conflicts with custom gesture libraries
  • Inability to achieve native-like UX

🔁 Steps to Reproduce

  1. Create a web app with custom gesture handling
  2. Add touch/pointer event listeners with preventDefault()
  3. Perform horizontal swipe (trackpad or mobile)
  4. Observe browser navigates back/forward instead of respecting app logic

🧪 Workarounds Attempted

  • overscroll-behavior: none
  • Touch and pointer event interception
  • Passive event overrides

❌ None reliably prevent browser navigation gestures across environments


💡 Proposed Solutions

Option 1: New Cancellable Event

window.addEventListener("browserswipe", (event) => {
  if (event.direction === "left" || event.direction === "right") {
    event.preventDefault(); // Prevent navigation
  }
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions