Elements are randomly glitching out with CSS transitions in Firefox

Chrome is working perfectly for me, but when I switch to Firefox it behaves differently than expected

I am attempting to create a simple animation (utilizing transitions) that continuously runs on mouseover and smoothly returns to the starting position on mouseout

The issue lies in the inconsistent behavior in Firefox

Below is a condensed version of my code demonstrating the current problem:

var arcs = $("#logoSec");
var greenarc = $(".greenarc");

var garcMs = 2100; // In ms
var arcsAnimBool = false; // If set to false, stops the animation loop

greenarc.css({
  transition: "transform " + (garcMs * 1) + "ms ease-in-out"
});

function greenArcNormal() {
  if (!arcsAnimBool) return;
  greenarc.css("transform", "rotate(70deg)");
  setTimeout(greenArcRevert, garcMs); // Initiates reverse rotation after garcMs milliseconds
}

function greenArcRevert() {
  if (!arcsAnimBool) return;
  greenarc.css("transform", "rotate(-70deg)");
  setTimeout(greenArcNormal, garcMs); // Restarts normal rotation after garcMs milliseconds
}

arcs.hover(
  function() { // On mouseover
    arcsAnimBool = true;
    greenarc.css({
      transition: "transform " + (garcMs * 1) + "ms ease-in-out"
    });
    greenArcNormal();
  },
  function() { // On mouseout
    arcsAnimBool = false; 
    greenarc.css("transform", "rotate(0deg)"); 
    greenarc.css({
      transition: "transform " + (garcMs * 0.5) + "ms ease-in-out"
    });
  }
);
  #ArcsLogo {
    height: 550px;
  }

  #logoSec {
    display: flex;
    background-color: #fdfdfd;
  }
<div id="logoSec">
  <svg class="arcs" version="1.1" id="ArcsLogo" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="-12 30 383.4 407.5" style="enable-background:new 0 0 383.4 407.5;" xml:space="preserve">
        <style type="text/css">
            .greenarc {
                fill: #00ff00;
                transform-origin: 50% 50%;
            }

            .graycircle {
                fill: #5d5d5d;
                transform-origin: 50% 50%;
            }

            .redarc {
                fill: #ff0000;
                transform-origin: 50% 50%;
            }
        </style>
        <path id="GreenArc" class="greenarc" d="M201.1,62.7c-3.2,0-6.3,0.1-9.4,0.3c77.7,5.5,136.2,72.9,130.7,150.6
                c-4.9,70-60.7,125.8-130.7,130.7c3.1,0.2,6.3,0.4,9.4,0.4c77.9,0,141-63.1,141-141S279,62.7,201.1,62.7L201.1,62.7z" />
        <circle id="GrayCircle" class="graycircle" cx="191.7" cy="203.7" r="21.2" />
        <path id="RedArc" class="redarc" d="M60.2,203.7c0-84.6,65.9-154.6,150.4-159.6c-3.1-0.2-6.3-0.3-9.5-0.3
                C112.8,43.2,40.7,114.2,40,202.5c-0.7,88.3,70.3,160.4,158.6,161.1c0.8,0,1.7,0,2.5,0c3.2,0,6.3-0.1,9.5-0.3
                C126.2,358.3,60.2,288.3,60.2,203.7z" />
    </svg>
</div>

(View simplified code on jsfiddle) https://jsfiddle.net/Ferdam/htxcwanu/28/

(Previous full code link: https://jsfiddle.net/Ferdam/9kz52e6h/3/)

I have limited experience with HTML/JS/JQuery/CSS so there might be some fundamental aspects that I am overlooking.

Your assistance is greatly appreciated. Thank you!

Edit:

Quoting directly from my response to nivoli:

I neglected to mention that I attempted using keyframes previously, however, I encountered an issue where elements 'teleported' back to their initial positions upon hoverout, prompting my shift to css transitions instead. I faced difficulty in animating the elements back to their starting positions using keyframes

Answer №1

Avoid using javascript and utilize css animations instead. I have implemented the green animation for your convenience:

#ArcsLogo {
  height: 550px;
}

#logoSec {
  background-color: #fefefe;
}

.greenarc {
  fill: #00ff00;
  transform-origin: 50% 50%;
  transform: rotate(70deg);
  animation: myRotate 4200ms alternate infinite ease-in-out;
}

.graycircle {
  fill: #5d5d5d;
  transform-origin: 50% 50%;
}

.redarc {
  fill: #ff0000;
  transform-origin: 50% 50%;
}

@keyframes myRotate {
  0% {
    transform: rotate(70deg);
  }
  100% {
    transform: rotate(-70deg);
  }
}
<div id="logoSec">
  <svg class="arcs" version="1.1" id="ArcsLogo" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="-12 30 383.4 407.5" style="enable-background:new 0 0 383.4 407.5;" xml:space="preserve">
        <path id="GreenArc" class="greenarc" d="M201.1,62.7c-3.2,0-6.3,0.1-9.4,0.3c77.7,5.5,136.2,72.9,130.7,150.6
                c-4.9,70-60.7,125.8-130.7,130.7c3.1,0.2,6.3,0.4,9.4,0.4c77.9,0,141-63.1,141-141S279,62.7,201.1,62.7L201.1,62.7z" />
        <circle id="GrayCircle" class="graycircle" cx="191.7" cy="203.7" r="21.2" />
        <path id="RedArc" class="redarc" d="M60.2,203.7c0-84.6,65.9-154.6,150.4-159.6c-3.1-0.2-6.3-0.3-9.5-0.3
                C112.8,43.2,40.7,114.2,40,202.5c-0.7,88.3,70.3,160.4,158.6,161.1c0.8,0,1.7,0,2.5,0c3.2,0,6.3-0.1,9.5-0.3
                C126.2,358.3,60.2,288.3,60.2,203.7z" />
    </svg>


</div>

The important step is to create the keyframes, which mirrors the transform functionality previously achieved through javascript. By applying the animation property to the greenarc class, we instruct it to

  • utilize the myRotate keyframes (you can rename this as needed)
  • transition from 0% to 100% over 4200ms. I extended this duration since I believe your script required 2100ms to move from rotate(0) to rotate(70).
  • alternate the animation direction to achieve a back-and-forth motion rather than a one-way movement.
  • repeat the animation infinitely
  • apply an ease-in-out effect to mimic the gradual slowing near the endpoints, similar to your javascript implementation.

Refer to the animation documentation for further guidance and examples.

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

Utilizing Angular2 Guard to Ensure False IdentityServer4 OIDC Security

After successfully authenticating a user and redirecting them back to the main site, the following code runs: <script src="https://cdnjs.cloudflare.com/ajax/libs/oidc-client/1.2.2/oidc-client.min.js"></script> <h1 id="waiting">Waiting... ...

Setting maxFontSizeMultiplier for all Text components

Is there a way to apply the prop maxFontSizeMultiplier={1} to all instances of <Text/> in my app without the need for a custom component? ...

Using an image tag with dual quotes in Vue.js

I am currently working on a feature where users can upload an image and then have it displayed after the upload is complete. However, I am facing an issue where the response link of the image contains a double quote, and when I use the <img> tag to ...

Creating a grid cell that spans the entire grid width

Snippet of CSS Code: .wrapper { display: grid; position: relative; grid-template-columns: repeat(4, 1fr); grid-auto-rows: 25vh; width: 100%; } .prova { border: 1px solid; } .wrapper div:nth-child(2) { grid-column: 3; grid-row: 2 / 4; ...

Ways to resolve the array to string conversion issue in PHP

In my PHP project, I am dealing with a dynamic array and trying to store the array result in a variable. However, I encountered an error: array to string conversion while coding. <?php require_once('ag.php'); class H { var $Voltage; ...

Is it possible to schedule a periodic GET request on the server-side without utilizing the client-side or frontend?

I am currently implementing a GET request to retrieve data from a third-party API. I want to regularly check for new data every 5-10 minutes on my backend. exports.get_alerts = async (req, res) => { const alertsUrl = `https://www.g2smart.com/g2smart/a ...

Examining the scroll-down feature button

I'm currently experimenting with a scroll down button on my website and I'm perplexed as to why it's not functioning properly. <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" c ...

Transmitted only JSON data instead of using multiform data with jQuery Ajax

When I use jQuery Ajax to send a JSON object, it ends up being interpreted as 'multiform' instead of pure JSON. How can I make sure my request is sent as a pure JSON object and not multiform? var demo = new Array("One", "Two", "Three"); $.ajax ...

Crashes within an HTML5 Canvas

Having recently started to explore Javascript and working with canvas elements, I've encountered a roadblock when trying to implement collision detection for the canvas walls. Typically, I have a small square drawn on the canvas that I can move aroun ...

The front-end is responsible for removing the last item from an array

Having an issue with my React code. Here is my parent component: class RoomPrice extends React.Component { constructor(props){ super(props) this.state = { room: this.props.room, prices: [] }; this.handleDeletePrice = this.h ...

Get started with adding a Typescript callback function to the Facebook Login Button

I am in the process of implementing Facebook login into my Angular7 application using Typescript. Although I have successfully integrated Facebook's Login Button plugin for logging in, I am facing issues with providing a callback method to the button& ...

Ensuring a form is required using ng-validate

A sample form structure is shown below: <div class="row" id="yesAuth"> <div class="col-md-6" ng-class="{ 'has-error': invalid.basicAuthForBackendUsername, 'has-success': valid.basicAuthForBackendUsername}"> < ...

Bootstrap revamps dropdown menu code into a convoluted mess

I recently started working on a project with the Material Design theme from for a CodeIgniter application. However, I've encountered an issue with the dropdown functionality. It seems that Bootstrap is altering the original code, transforming it from ...

Having trouble transferring information from a form to a page because of the error message " is not defined"?

I'm facing an issue while building a node app. I have set up my routes correctly and installed all the necessary dependencies. However, when I try to load the ("/) "homepage," I receive an error message stating that "newPost" is not defined. Surprisin ...

When users click on the next/link, it is triggering a problem within the getInitialProps function

Currently, I am attempting to include a link that will direct users to the create page. However, when I tried clicking on the link, I encountered the following error: TypeError: Cannot read properties of undefined (reading 'cookies') The code fo ...

Ionic version 4 ion-img eagerly preloads images instead of implementing lazy-loading

I recently created a horizontal scroller using FlexLayoutModule. It allows me to display a horizontally scrollable list where each item consists of an image and text column. Here's the relevant snippet from my scroller.component.html: <div class=" ...

choose an option with the jquery method and create it

Creating a dynamic select option based on the user's selection of year from two arrays, "year" and "month". For example, if 2011 is selected, then the corresponding months will be displayed in the next dropdown. If 2009 is selected, the next dropdown ...

Two adjacent divs positioned next to each other, where the right-hand div occupies the remaining space within its

I am facing a common issue with two side-by-side divs, which I usually solve without any problems by floating both divs left and adding a clear:both div after them. However, my requirements have made this problem more complicated to solve... What I would ...

Evaluating manually bootstrapped AngularJS applications

I've encountered an issue while testing an AngularJS application (using Karma and Jasmine) where I manually bootstrap the application in the code after some HTTP AJAX requests. angular.module("app", []); angular.element(document).ready(function() { ...

Creating a React render method that relies on both asynchronous requests and state changes

Currently, I am immersing myself in the world of ReactJS and Redux. However, I have encountered a hurdle that seems insurmountable to me. In one of my projects, I have a React component that is responsible for fetching data asynchronously. export class M ...