Struggling to get the hang of CSS animation?

Here is a code snippet that I am using:

//Code for animating skills on view
document.addEventListener("DOMContentLoaded", function(event) {

  function callback(observations, observer) {
    observations.forEach(observation => {
      if (observation.isIntersecting) { //IF IT'S IN VIEW
        observation.target.classList.add('animated');
        observation.target.classList.add('animated1');
      } else {
        observation.target.classList.remove('animated');
        observation.target.classList.remove('animated1');
      }
    });
  }

  // SETTING UP AN INTERSECTION OBSERVER
  let options = {
    root: null, 
    rootMargin: '0px',
    threshold: 1.0 
  }

  let observer = new IntersectionObserver(callback, options);

  
  let spans = document.querySelectorAll('span');
  for (let i = 0; i < spans.length; i++) {
    observer.observe(spans[i]);
  }
  let spans1 = document.querySelectorAll('line');
  for (let a = 0; a < spans1.length; a++) {
    observer.observe(spans1[a]);
  }
});
.master {
  display: flex;
}

.master div {
  width: 98.6%;
}

@media all and (max-width: 500px) {
  .master div {
    width: 99.9%;
  }
}

@media all and (max-width: 500px) {
  .master {
    flex-flow: wrap;
  }
}

.column-adjustment {
  float: left;
  width: 50%;
  padding: 5px;
}
...
<div class="master">
  ...
</div>

The issue arises when trying to animate elements on iOS devices such as iPhone 14 where the animation glitches like this:

https://i.sstatic.net/sPYMh.gif

I have tried solutions mentioned in this post about CSS animations not working in iOS, including adding web-kit, but the issue still persists. Any insights into why this problem occurs specifically on iOS devices?

Answer №1

It appears that the issue lies in animating (pseudo) children of observed elements, causing these elements to become wider than the viewport (especially in Safari). This results in them no longer meeting the threshold: 1 condition, leading to a removal of the class and subsequent shrinking back, ultimately resulting in an infinite loop.

I have observed similar behavior on my Firefox when I narrow the viewport significantly.

To confirm this, I recommend:

  • Reducing the threshold to 0.0 to see if it resolves the issue,
  • Applying a debug outline to all observed elements to track when they exceed the viewport,
  • Inserting console.count('intersecting') within the observation.isIntersecting branch to monitor how often it is triggered.

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

Tween.js - Can you animate a variable using tweens?

Recently, I've been experimenting with three.js and tween.js and I'm curious if it's possible to animate a variable using tweening? Here are some of my attempts: 1) tween = new TWEEN.Tween(renderergl.toneMappingExposure).to( "0.001&qu ...

Tips for saving the status of an accordion controlled by an angular directive

I am currently utilizing the accordion directive from angular-bootstrap. My goal is to save the is-open attribute of this accordion, so that when users navigate to another page on the website, the state of the accordion (i.e. is-open) remains unchanged. ...

The length of JSON data retrieved may vary between Internet Explorer and Firefox

After receiving JSON data from the server via AJAX, I proceeded to evaluate it as follows: request.responseText=[{name:xxx},{name:yyy},{name:zzz}]. I then used the following code snippet: var data=eval(request.responseText); alert(data.length); Surpri ...

Tips for uploading an image file from Django Admin to the HTML

If I have already used a for loop in my code, how should I write the image address if I don't want to use 'for'? Can I directly write something like '/img/1.jpg'? Here is the directory where my images are stored: This is my Djang ...

Using AngularJS to incorporate ng-include with ng-click functionality

I am trying to figure out a way to insert HTML that is specifically optimized for the controller into an alert div. Unfortunately, I have been unsuccessful so far... <script type="text/ng-include" id="login.html"> <form data-select="exepti ...

JavaScript anchor scrolling

I am currently working on building a website with anchor navigation similar to what is used on platforms like Facebook and Google Mail. I have managed to get it partially working, but there are still some issues. For example, when I load the page with some ...

Is it possible to determine if child_process has finished in node.js?

I'm currently in the process of developing a cakefile with node.js and I need to determine whether a child_process has completed before proceeding to the next one. {exec} = require 'child_process' exec 'casperjs test.js', (err, s ...

Working with Typescript to map and sort the key values of a new datasource object

Managing a large datasource filled with objects can be challenging. My goal is to rearrange the order of objects in the array based on new values for each key. Whenever a new value for a key is found, I want the corresponding object to move to the top of t ...

Retrieve data from a JSON array using either JavaScript or PHP

Check out my code snippet: const newData = [{"new_id":"1","new_no":"1","total":"N.A"},{"new_id":"2","new_no":"3","total":"4"},{"new_id":"2","new_no":"4","total":"5"}]; Now, I need to extract specific details from this JSON data based on the 'new_no& ...

The steps to properly load "child.vue" into the correct position within "parent.vue" are as follows

Currently I am developing a single page web application using Vue.js. This app consists of 4 "page.vue" files, each with a right and left child .vue component nested inside. For instance, the Page1.vue file is structured as follows (omitting style and scr ...

How can one use Selenium to verify the existence of an element on a webpage?

Currently, I am developing a program in Selenium with Python and facing an issue. During the test execution, there is a possibility that a button may or may not appear on the webpage based on an unknown parameter. The relevant HTML tag for this button is ...

Issues encountered while trying to style an unordered list using the table-cell property

I am having trouble formatting the "How it works" section on my website. When the text is too long, the numbers on the left side grow alongside it as shown in number 4. Is there a way to keep the numbers fixed on the left while allowing the text to expand ...

Div with a vertical line

Check out this jsFiddle link Struggling to get a "vertical rule" to span the entire width of its container in a div, specifically adjusting the border-right of a nested div. Margins have been modified, even tried margin-top: 20px; in the #vr, but no luck. ...

Having trouble getting the waveform to load in IOS Safari when using WavesurferJS in a VueJS application, even though the audio is playing fine

In my VueJS application, I've been facing a challenge with WavesurferJS on IOS Safari for the past week. The issue is that the wavesurfer component cannot fully decode the audio or load the waveform, resulting in just a thin straight line being displa ...

The clash between React Inline styles and Client CSS can lead to conflicts in styling

Our application needs to be loaded into the client's page, which is built using React. We are implementing React Inline Styles by defining styles as objects. However, we have encountered an issue where any CSS specified by the client using tag attribu ...

When a card is clicked in the parent component, data is sent to the child component in Angular. The card contains an image, name, ID,

How can I pass data from a parent component (nfts) to a child component (main) when a card is clicked? The card contains images, ids, names, and more information. I've attempted using @Input() but haven't been able to receive the value in the ch ...

Bootstrap 3 Implementation of a Clear Navbar

I'm trying to create a transparent navbar using the code below: <div class="navbar navbar-default navbar-fixed-top" style="top:50px; background:transparent;"> <div class="navbar-inner"> <div class="container"> <ul cla ...

How can one identify a concealed glitch that exclusively occurs for a particular individual or hardware in a React environment?

Is it possible to identify a bug that occurs only with a particular individual or hardware in a React application? This bug is invisible and never appears during tests, but only manifests with a specific client within my company. Do you have any tips on h ...

Accordion content in motion

After creating an accordion, I wanted to enhance the user experience by adding a transition effect whenever they click on the accordion header. Even though I included height: auto and transition in the accordion container, it did not seem to have any impa ...

Troubleshooting my nodejs websocket chat for message sending glitches

The chat system is built on nodejs using websockets from socket.io library. While I have a client that also utilizes websockets from socket.io, I'm facing challenges in making the two communicate effectively. The issue seems to be with the client not ...