Can the swipe navigation feature be disabled on mobile browsers?

Currently, I am in the process of creating a VueJS form that consists of multiple steps and includes a back button for navigating to the previous step. The steps are all managed within a parent component, which means that the URL and router history remain unchanged throughout the form.

One issue I am facing is that when a user swipes on their phone screen, the browser automatically navigates to the previous page in the browsing history. Ideally, I would like to modify this behavior so that the swipe gesture functions the same as the back button on my form (allowing users to navigate between form steps rather than pages) or disable it entirely.

Attempts to address this issue have included:

  • Applying touch-action: none to the body and html elements
  • Setting overscroll-behaviour: none on the body and html tags
  • Using preventDefault() on both touchstart and touchmove

Despite these efforts, it appears that the swipe behavior remains unaffected by the web application. Is there a solution available to prevent unwanted navigation from occurring?

As of now, I am conducting tests on Safari iOS using the xCode simulator; however, any solution should be compatible with both iOS and Android devices.

Answer №1

To find the solution, refer to the feedback provided by @Ohgowhy

In order for the event listener to function properly, it was necessary to include { passive: false } as a parameter. While this resolved the issue on most mobile browsers, there was still an incompatibility with Firefox on Android.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What are the reasons behind my item not triggering an alert even after I have created it, saved it, and attempted to alert it?

I am currently working on a code that allows users to input information which is then stored in an object. However, despite my efforts, when I attempt to retrieve the saved object by alerting one of its values, it indicates that the object does not exist. ...

Problem with jQuery Window Resize Trigger Not Reactivating

I am facing a challenge in integrating a slider within multiple jquery tabs. As the slider requires specific width and height to display correctly, I have to trigger a window resize event when the tabs are switched. Surprisingly, the code I implemented onl ...

Personalized typeface for stencil.js element

I am currently working on a stencil component and I need to specify a font for it. Here is what I have so far: index.html <body> <sidebar-component webpagename="dashboard"></sidebar-component> </body> <style> * { m ...

Is there a substitute for useState in a Next.js server component?

With my static site at , the only interactive feature being the dark mode toggle, I understand that using useState is not feasible in a server component. export default function RootLayout({ children }: { children: React.ReactNode }) { const [darkMode, ...

Eliminate the commas when listing Google Places types

I am currently utilizing the Google Places API and came across these code snippets at https://developers.google.com/maps/documentation/javascript/examples/place-search-pagination. var map, placesList; function initialize() { var pyrmont = new google.ma ...

Is there a restriction on the number of strings allowed in minimist?

Here is the output received from the code provided below. Question input and i are both true as intended, but why aren't project and p? They are defined in exactly the same way as input and i. $ bin/test --input -p { _: [], update: fa ...

When running GPUImage Harris Corner Detection on a given UIImage, the resulting image is completely black

I have successfully implemented a crosshair generator and Harris corner detection filter on live video from a GPUImageStillCamera output. However, when trying to apply these filters to a photo displayed on a UIImageView, I only end up with a black screen a ...

Retrieving data from an API after the onClick event is activated

I'm facing a bit of a challenge with an HTML & JavaScript issue, which I believe should be straightforward to resolve. Since frontend development is not really my forte, I am hoping to find some assistance here. Task: A friend who owns a website buil ...

Maxlength and Minlength attributes are not considered when using input type=“number”

Why is the maxlength attribute not functioning properly for this input element? <input type="number" maxlength="5" maxlength="10" /> ...

Loading files using $scriptjs or any other asynchronous loader allows for seamless integration of external resources

Imagine I have developed an AngularJS application that lazy loads controller files (using $scriptjs) and all dependencies when the user navigates to a specific route. This application consists of 3 routes: A, B, and C. My question is: if the user navigate ...

Order of Execution for Nested Promises

Curious about nested promises, I came across this coding challenge in my tutorials. Can someone shed some light on the execution order of this code? new Promise((resolve) => { new Promise((res) => { console.log("c"); resolve(3); ...

What is the process for generating a new file using an iPhone .xib file?

When I start a new project in Xcode, it offers me the choice to add an iPad-sized .xib file. Is there a way for me to obtain the .xib file in iPhone size instead? ...

I'm currently experiencing a challenge with a project I'm tackling that specifically deals with chart.js

In my recent coding project, I created a script to gather user input and then present it in various chart formats. However, upon executing the code, the selected chart fails to display after inputting values and clicking on the "generate chart" button. Her ...

Tips for transforming a Vue 2 website into a progressive web application (PWA) were requested

As I explored the PWA functionality in Vue 3, I noticed that it is not available in Vue 2. If anyone has any insights on how to successfully convert a Vue 2 project into a PWA, I would greatly appreciate your input. Thank you! ...

Mastering the art of utilizing class attributes and functions from within modules

Currently, I am developing classes in ES6 modules using object literals and my intention is to update object attributes within a function. Although modules run in strict mode by default which ensures safe usage of this, I am uncertain whether calling the ...

Is there a way to convert a PHP array into a JavaScript object and return it?

When I have an array defined and encode it using json_encode() $array = array("a" => "element1", "b" => "element2"); echo json_encode($array); The usual JSON output is: {"a":"element1","b":"element2"} However, my interest lies in getting this out ...

Implementing DeviceEventEmitter in an iOS Environment

I'm currently developing a react-native application. I've encountered an issue where I am able to emit events from native Android code to my react native app successfully, but facing difficulties with iOS. While the events sent from native Andro ...

Receiving an unexpected error message related to Vuex in the watcher function, even though I am not utilizing Vuex in my N

My goal is to update an object property in an array [{ text: 'some text' value: 'some value, active: false }, etc..] from false to true when I click on a checkbox that is connected to a v-model: <v-col v-for="(item, i) in searchModul ...

Is it possible to determine if the clipboard is accessible in Firefox?

In my upcoming JavaScript project, I am looking to determine the accessibility of the clipboard. Particularly in Firefox where specific permissions need to be granted for each site in order to use certain functions like execCommand with cut, copy or past ...

Guide to altering the characteristics of a button

Here is the code for a button within My Template: <div *ngFor="let detail of details" class = "col-sm-12"> <div class="pic col-sm-1"> <img height="60" width="60" [src]='detail.image'> </div> <div ...