Why are divs appearing over a three js animation when scrolling down on a desktop but not on a mobile device?

I have a Three js animation in the body of the document:

container = document.createElement( 'div' );
document.body.appendChild( container );

There are two overlaying divs set with the following styles:

#holder {
  z-index: 1;
  position: absolute;
  top: 0px;
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  overflow-y: scroll;
}

#sitearea {
  width: 1000px;
  margin: 0 auto;
}

In addition, there is a media query included:

@media screen and (max-width: 1000px) {
  #sitearea {
    width: 100%;
  }
}

The animation can be interacted with using the following events:

document.addEventListener( 'mousemove', onDocumentMouseMove, false );
document.addEventListener( 'touchstart', onDocumentTouchStart, false );
document.addEventListener( 'touchmove', onDocumentTouchMove, false );

On desktop, the animation reacts to mouse movements, while on mobile it responds to touch.

It is possible to scroll the holder div down on desktop to reveal more text without moving the background animation.

Unfortunately, the holder div does not respond to touch on mobile devices, preventing the ability to slide up any additional text.

Answer №1

Include the following functions:

function onTouchStart() {
  var container = document.getElementById("container");
  container.addEventListener( 'touchstart', onTouchStart, false );
}

function onTouchMove() {
  var container = document.getElementById("container");
  container.addEventListener( 'touchmove', onTouchMove, 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

Error: Webpack is unable to load PDF file: Module parsing unsuccessful. A suitable loader is required to manage this file format

I am relatively new to using webpack for my projects. Recently, I wanted to incorporate a feature that involved displaying PDFs. After some research, I came across the "react-pdf" library and decided to give it a try. While everything worked smoothly in a ...

What is the purpose of storing JSON data as a string within another JSON object?

Screenshot of developer tools While exploring the local storage on my visit to YouTube, I came across some very peculiar-looking JSON data. { creation: 1638112285935, data: "{\"quality\":1080,\"previousQuality&bs ...

Retrieving FormData() parameters sent via Ajax with PHP

After successfully testing FormData() with jQuery.ajax, I encountered a roadblock when trying to implement a progress bar for file uploads using the same method. This led me to use AJAX directly and post form data, but unfortunately, retrieving the form da ...

Error encountered with Ajax client-side framework while executing HTML code

When I run my project from Visual Studio using an aspx page that utilizes ajax modal popup extender, everything works fine with IE and Firefox as the default browsers. However, when I create an HTML file containing the code and open it by double-clicking, ...

Running Node.js on a cluster of Raspberry Pi devices

After completing a cluster of four nodes using Raspberry Pi by following this tutorial from the University of Southampton, I now aim to deploy a Node.js web server application on this cluster utilizing MPI or other methods. What is the most efficient way ...

Which is the ideal library for creating this specific chart - shown in the image in the description - in reactjs?

After numerous unsuccessful attempts, I have finally decided to seek help in creating this chart. I would highly appreciate any assistance that can be provided. https://i.sstatic.net/jtQ3I.jpg ...

Executing gruntfile from the devDependencies module

Currently, I am testing out a .js framework. Within my package.JSON file, specifically inside devDependencies, I have the following: "devDependencies": { "myFramework": "https://github.com/myRepo/myFramework/tarball/master", "grunt": "~0.4.2", ...

Utilizing camera perspective for coordinate system in Three.js

This question may seem basic, but I'm having trouble grasping it. I'm working on a scene using Three.js and the camera setup is as follows: var camera = new THREE.PerspectiveCamera( 85, window.innerWidth/window.innerHeight, 0.1, 1000 ); camera. ...

Splitting the div into two columns

I've encountered various solutions to this issue, but when I integrate an Angular2 component inside the divs, it fails to function properly. Here is my progress so far: https://i.stack.imgur.com/qJ8a9.jpg Code: <div id="container"> <div ...

Updating a specific property for each object within an array of objects in MongoDB, and inserting the object if it does not already exist

I am looking for a solution to update a property for each object in an array of objects. If some of the objects do not exist, I want to insert the missing objects instead. Currently, I have been using "upsert", which creates a new document when no documen ...

Vertical scrollbar in iframe unexpectedly appears immediately after the submit button is pressed

I have designed a contact form that is displayed in an iframe within an overlay div. I have carefully adjusted the dimensions of this div to ensure that there are no scrollbars visible when the form initially appears. However, after filling out the form an ...

Dealing with errors in Node.js using the Express framework and the

The code I'm having trouble with is shown below app.get('/', function(req, res, next) { if (id==8) { res.send('0e'); } else { next(); } }); app.use(function(err, req, res, next){ res.send(500, ' ...

Learn the simple technique for creating smooth 3D object animations when clicking using Three.JS

As someone who is just beginning to explore Three.JS and 3D web development, I am eager to recreate a specific action that I saw in this video: https://www.youtube.com/watch?v=HWSTxPc8npk&feature=youtu.be&t=7s. The concept involves a group of 3D pl ...

Creating a React component that initializes its state with an empty array

Currently, my component is designed to fetch data from an API and store a random selection of objects (currently set at 10) in an array called correctAnswerArray. To avoid selecting the same object more than once, I use the splice() method. After pushing t ...

Angular 2 can efficiently generate multiple HTTP requests simultaneously from a single HTTP request

Backend API's: url: [ { "name": "ABC", "occupation": "Student", "address_url": "http://www.sample.com/address/person=hgjgjgyyfhg" }, { "name": "ABC1", "occupation": "Carpenter", "address ...

Angular transitions do not smoothly animate when a new component is added

Exploring ways to animate the appearance and disappearance of a new Angular component in my application has been quite challenging. Referencing the guidelines provided by Angular itself at https://angular.io/guide/transition-and-triggers#enter-and-leave- ...

Utilizing the power of Vue.js version 2.x alongside the sleek features of Bootstrap

I'm currently experimenting with incorporating Bootstrap 5 into Vue (2.x) without relying on any third-party libraries. My approach involves creating a custom wrapper for select Bootstrap components that I intend to utilize. For guidance, I've b ...

Guide to configuring a service worker to manage the main website path

My website is hosted at https://xxxxxx.com. I have set the scope of the service worker file sw.js to /, but it seems that the service worker is unable to control the page https://xxxxxx.com. However, it can control other pages like https://xxxxxx.com/, e ...

Tips on utilizing CSS modules in React without changing class names

After starting to use css modules in my react project, I quickly realized the struggle of changing classnames to fit the requirements of css modules. For example, if we have a component using regular css: import React from 'react' import ". ...

Creating a dynamic 2D image using HTML5 animation

As a beginner HTML5 developer, I have been exploring ways to create an animated image using multiple jpg files stored in a specific folder on my website. My goal is to design an animation of a rabbit running across the page when a user clicks on a button. ...