Prevent unwanted bouncing and zooming on IOS10+ when using routing in VueJS

Currently, I am developing a Vue.js application that integrates with Three.js to display 3D models. I am using Vue.js with Vuetify as the framework and incorporating the Vue.js router.

Due to the nature of displaying 3D models, I need to prevent zooming in the browser and disable certain gestures on smartphones to avoid unwanted interactions such as accidental page reloads. To achieve this, I have added the following meta tag:

<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

Unfortunately, this approach does not work on IOS10+, so I have implemented InoBounce.js as a workaround to address this issue.

While the script functions correctly on the initial page load, it fails to maintain its functionality when navigating between pages via buttons. This could be due to compatibility issues with vuejs integration, as the script creator may not have designed it with Vue.js in mind.

To resolve this, I attempted to re-run the script through a watcher when route changes occur. I modified the script to export a method instead of creating itself globally, stored it in Vuex for global accessibility, and called it every time the route changed. Here is an example:

 watch: {
   $route(to, from) {
     this.$store.state.bounceFix.fixBounce();
  },
 },

Despite confirming that the method is invoked during route changes, the script continues to only function on the main page upon initial load (since I also call it in the "mounted" lifecycle hook).

Thus, I am left wondering if I am one of the few individuals seeking to disable zooming in conjunction with a complex framework like Vue.js, given the limited resources available online addressing this specific challenge.

What is considered the most effective method to restrict zooming and bouncing in Safari while utilizing Vue.js?

UPDATE:

I overlooked an essential aspect:

In addition to the previous steps, I had to include the following CSS properties within my <style> tag:

overflow: auto;
    -webkit-overflow-scrolling: touch;

This adjustment aims to eliminate gestures such as "swipe to refresh."

Answer №1

Would you be willing to give this a shot?

<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">

Answer №2

After some troubleshooting, I managed to find the solution to my issue. The root of the problem lied in the event listeners within the inobounce script being assigned to the "window" element. By making a simple adjustment to target the "document" element instead, I was able to resolve the issue successfully.

This involved changing:

window.addEventListener('touchstart', handleTouchstart, supportsPassiveOption ? { passive : false } : false);

To this:

document.addEventListener('touchstart', handleTouchstart, supportsPassiveOption ? { passive : false } : false);

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

Improve the efficiency of the function for retrieving data from a lengthy string and organizing it into key-value pairs within an object

I am dealing with a string extracted from a text file, which is structured in the following way on each line. 1=abc|2=TsMarketDataCache|3=1|4=141061|6=2023-02-27T05:04:50.472|36=F|7=1584A Format: key1=value1|key2=value2|key3=value3|key4=value4...|keyN=va ...

Loading data dynamically in the Highcharts ng library allows for real-time updates to the

I'm currently working on integrating highcharts ng into my Angular project, but I'm encountering issues with data not populating. It seems like there might be a problem related to the loading of the DOM and the function call. Here's my HTML ...

What could be causing this error in a new Next.js application?

After multiple attempts, my frustration and disappointment in myself are causing a headache. Can someone please assist me? I am trying to create an app using the following command: npx create-next-app@latest --ts Immediately after running next dev, I enco ...

What are the steps to incorporating an Image in a React Native application?

My Image is not showing up when I try to render it using image uri, and I'm not sure why. Here is the code snippet I'm using in a React Native project. import React from 'react'; import styled from 'styled-components/native'; ...

Selenium unable to interact with Javascript pop-up box

I am currently working on automating a feature for our web application, specifically a form of @mentioning similar to Facebook. On the front end, when a user types @ into a text input, the API is called to retrieve the list of users and display them in a b ...

What is the most efficient way to transfer a large volume of documents from mongoDB using http?

I'm dealing with a large mongoDB database that contains millions of documents and I need to fetch them all at once without crashing or encountering cursor errors. My goal is to send this data over http using express in nodeJS. The collection contains ...

Is there a method for removing the Microsoft Translator widget while still keeping the translation feature intact?

I am currently utilizing the Microsoft Translation Widget to automatically translate a webpage without requiring any user interaction. Unfortunately, I have been facing an issue where I am unable to remove or hide the widget that keeps popping up on the p ...

Issue with Angular 18 component not being displayed or identified

Recently, I began building an Angular 18 application and encountered an issue with adding my first component as a standalone. It appears that the app is not recognizing my component properly, as it does not display when added as an HTML tag in my app.compo ...

With Crypto-JS, a fresh hash is always generated

I'm looking to integrate crypto-js into my Angular 8 application. Here is a snippet of my code: import {Injectable} from '@angular/core'; import * as CryptoJS from 'crypto-js'; @Injectable() export class HprotoService { public ...

Changing the value of an object property (illustrated using a basic linked list)

I am working on a JavaScript Link List implementation as a beginner, and I have written the following code: var LinkList = function () { this.LinkedList = { "Head": {} }; }; LinkList.prototype = { insert: function (element) { var Node = this ...

Setting default property values in a React component using Typescript

   Is there a way to define default property values in React components when using Typescript? I came across a post on SE suggesting the use of a static class variable called defaultProps with key-value pairs for properties. However, this method didn&a ...

Passing information from a parent component to a child component in Vue.js

Good evening. I am currently working on a chat application built with Laravel and Vue.js. I have successfully listed all the messages for my users, but now I want to make conversations selectable so that when a user clicks on a conversation, only the messa ...

Generating components dynamically at runtime following an HTTP request in VueJS

Is there a way to conditionally render VueJS components based on an Http request immediately upon application launch? I want to display component 1 if the response is successful, otherwise display component 2. Additionally, I would like the rendering of th ...

How to successfully load the google-map-react library

After installing the google-map-react library locally in my app, I verified that it is listed in my package.json under dependencies. The corresponding folder also exists in the node_modules directory. However, when attempting to reference the component con ...

jQuery dynamic id selection

I'm facing a challenge with dynamically generated forms that have dynamically generated IDs and potentially classes. Although the forms are identical, they each have a unique ID at the end. How can I target and manipulate each set of inputs individua ...

JavaScript, detecting repeated characters

I need to create a script that checks an input box (password) for the occurrence of the same character appearing twice. This script should work alongside existing regex validation. I believe I will need to use a loop to check if any character appears twice ...

What happens if I don't associate a function or method in the React class component?

Take a look at this straightforward code snippet that updates a count using two buttons with different values. import "./App.css"; import React, { Component } from "react"; class App extends React.Component { // Initializing state ...

Preventing Content Changes When Ajax Request Fails: Tips for Error Checking

I was struggling to find the right words for my question -- My issue involves a basic ajax request triggered by a checkbox that sends data to a database. I want to prevent the checkbox from changing if the ajax request fails. Currently, when the request ...

Accessibility issues detected in Bootstrap toggle buttons

I've been experimenting with implementing the Bootstrap toggle button, but I'm having an issue where I can't 'tab' to them using the keyboard due to something in their js script. Interestingly, when I remove the js script, I'm ...

Having trouble removing a cookie in express?

Seems pretty straightforward. In the /user/login route, I set a cookie as shown below: if (rememberMe) { console.log('Login will be remembered.'); res.cookie('user', userObj, { signed: true, httpOnly: true, path: '/' ...