Choppy and Jerky CSS3 animation in Firefox on new "page load"
Asked Answered
O

3

6

I am trying to show a CSS3 animation as a loader-animation when I navigate to one of my subpages. I am using keyframe animation on rotateY. The issue is that on Firefox, while navigation to another page, the animation does work, but its very jerky and choppy.

While on Chrome and Safari, the same animation works smoothly and perfectly.

Here is a fiddle: http://jsfiddle.net/p6mgxpbo/

HTML:

<div class="gb-loading">
    <div id="animatedElem" class="pin-c">
        <div class='pin'></div>    
    </div>
    <div class="pin-mirror"></div>
    <div id="gb-lb" class="load-bounce"></div>
</div>

CSS:

.gb-loading {
        position: fixed;
        left: 0;
        right: 0;
        top: 50%;
        bottom: 0;
        width: 70px;
        height: 70px;
        margin: auto;
        z-index: 101;
        margin-top: -100px;
    }
    .pin-c {
        width: 70px;
        height: 70px;
        position: absolute;
        top: 0;
        left: 0;
        z-index: 11;

        -webkit-animation: pulsate 1.5s linear infinite;
           -moz-animation: pulsate 1.5s linear infinite;
             -o-animation: pulsate 1.5s linear infinite;
                animation: pulsate 1.5s linear infinite;
    }
    .pin {
        width: 70px;
        height: 70px;
        background-color: #34baab;
        position: absolute;
        left: 0;
        top: 0;

      -webkit-border-radius: 50% 50% 50% 0;
              border-radius: 50% 50% 50% 0;

      -webkit-transform: rotate(-45deg);
         -moz-transform: rotate(-45deg);
           -o-transform: rotate(-45deg);
              transform: rotate(-45deg);
    }

    .pin-mirror {
        width: 70px;
        height: 70px;
        background-color: #003146;
        position: absolute;
        left: 0;
        bottom: -48px;
        z-index: -1;

      -webkit-border-radius: 50% 0 50% 50%;
              border-radius: 50% 0 50% 50%;

      -webkit-transform: rotate(-45deg);
         -moz-transform: rotate(-45deg);
           -o-transform: rotate(-45deg);
              transform: rotate(-45deg);
    }

    .pin:after {
        content: '';
        width: 25px;
        height: 25px;
        margin: 22px 0 0 22px;
        background-color: #003146;
        position: absolute;

        -webkit-border-radius: 50%;
                border-radius: 50%;
    }

    .load-bounce {
        width: 25px;
        height: 25px;
        position: absolute;

        left: 65px;
        background-color: #003146;
        -webkit-transform: translateZ(0.5);
           -moz-transform: translateZ(0.5);
                transform: translateZ(0.5);

        -webkit-border-radius: 50%;
                border-radius: 50%;

        -webkit-animation: bounce .5s linear infinite alternate;
           -moz-animation: bounce .5s linear infinite alternate;
             -o-animation: bounce .5s linear infinite alternate;
                animation: bounce .5s linear infinite alternate;
    }

    @-webkit-keyframes pulsate {
        0% {

            -webkit-transform: rotateY(0deg);
        }          
        100% {

            -webkit-transform: rotateY(360deg);
        }
    }

    @-moz-keyframes pulsate {
        0% {

            -moz-transform: rotateY(0deg);
        }
        100% {

            -moz-transform: rotateY(360deg);
        }
    }

    @keyframes pulsate {
        0% {

            transform: rotateY(0deg);
        }
        100% {

            transform: rotateY(360deg);
        }
    }

    @-webkit-keyframes bounce {
        0% {
            -webkit-transform: translateY(-10px);

        }
        100% {
            -webkit-transform: translateY(-40px);
        }
    }
    @keyframes bounce {
        0% {
            transform: translateY(-10px);

        }
        100% {
            transform: translateY(-40px);
        }
    }

    @-moz-keyframes bounce {
        0% {
            -moz-transform: translateY(-10px);

        }
        100% {
            -moz-transform: translateY(-40px);
        }
    }

The jerk only comes when Its there on a page which is loading other resources. I am trying to use this element as a pre-loading animation. So it's on the page until the rest of the page is loading. I also have google maps on the same page. So, while the browser is downloading other resources, till that time the animation jerks. You'll not be able to see the jerk on the fiddle.

Need some insights on how to fix this. Thanks in advance !!

P.S: I did go through a lot of answers related to this on StackOverflow and tried searching on Google, but to no avail.

Octosyllabic answered 3/7, 2015 at 13:5 Comment(15)
Can you share your code please? Debugging it without seeing it is close to... impossible?Trustee
Sure. Here is a fiddle: jsfiddle.net/p6mgxpboOctosyllabic
You need to include the code in the question itself. otherwise it might be closed.Trustee
Works very smooth here.Amary
me too, I tried it in FF and chrome, no jerk.Trustee
@web-tiki: The jerk only comes when Its there on a page which is loading a lot of resources. I am trying to use this element as a pre-loading animation. So its on the page until the rest of the page is loading. I also have google maps on the same page. So, while the browser is downloading other resources, till that time the animation jerks. You'll not be able to see the jerk on the fiddle.Octosyllabic
@Rvervuurt: That's exactly my question. How do I make this animate smoothly whole the page is loading other resources because that's the case when its choppy otherwise it works perfectly fine. Also, in case of Safari and Chrome it works perfectly even when the page is being loaded. This specific issue is only with firefox.Octosyllabic
@ShubhamSharma: The problem is we cannot help to fix a problem that we are not able to see. So if you can't reproduce the behavior on a fiddle then an answer is going to be really hard to come by.Tournedos
@Harry: Finally Created a fiddle where you can see the issue. jsfiddle.net/74wcquvz/2 Here while the page loads, the animation becomes jerky only on firefox while the same thing works perfectly in Chrome and Safari.Convex
@Rvervuurt: Now you can see the issue in firefox.Convex
@web-tiki: Now you can see the issue in firefox.Convex
@Convex Uh, no I can't.Amary
@Harry: Yes, I initially signed in with a new ID as I did not remember the password for this Mechanicals ID.Convex
@Rvervuurt: For me, now the jerk is very much evident in firefox just before the rest of the page is loaded in the fiddle . Did you try the new fiddle i added jsfiddle.net/74wcquvz/2Convex
@mechanicals: Oh ok, no worries. I just wanted to be sure it was the same person and not somebody else. Anyway, I can't see any jerk either.Tournedos
A
10

Sadly, this is something that you will not be able to fix, amend or control with browsers. You will have to use some form of hack to get it to work or confuse the system into doing what you want, but from a normal render, it won't work.


What you could possibly do is add a delay to the animation.

-webkit-animation: pulsate 0.8s linear 10ms infinite;
-moz-animation: pulsate 0.8s linear 10ms infinite;
-o-animation: pulsate 0.8s linear 10ms infinite;
animation: pulsate 0.8s linear 10ms infinite;

JSFiddle Example

What this will do is let the page render, paint and display, then it will wait for 100ms (0.1s) before starting the animation.

If this doesn't work, then it's down to FF not rendering animations as cleanly as Chrome or some other browsers and that is simply a browser issue and will be exceedingly difficult to get round.


Every browser has a completely different tree, render and paint process for displaying HTML & CSS to your monitor. Gecko (FF) and WebKit (Chrome) both use completely different methods and processes to display the page and sadly, when it comes to doing animations, Gecko has the tiniest amount of lag when starting up the animation which is why you see the small bit of lag/jerkiness when the animation begins.

Webkit flow Webkit Flow

Gecko flow Gecko Flow

As you can see from the above flows, both flows are completely different and the way that the DOM is loaded in, rendered, painted and then displayed is completely different.

Hope this help clears up the issue.

I've added one of the best pieces of information for you to read up on about browser rendering. It's always good to have an understanding of how browsers work when working on the front-end.

Approver answered 10/7, 2015 at 13:27 Comment(0)
D
2

For some reason when you animate with Skew(0.1deg) it is not choppy. This is on firefox 91.0 (64bit).

.test {
    animation: breath2 0.8s linear 10ms infinite alternate;    
}
@keyframes breath2 { 
    0%  { transform: skewX(0.1deg) scaleX(1) translateY(-10px)}
    100% { transform: skewX(0.1deg) scaleX(0.95) translateY(10px)}
}

.button {
  border: 1px solid green;
  height: 50px;
  width: 150px;
  border-radius: var(--border-radius);
  position: relative;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  -webkit-box-pack: center;
      -ms-flex-pack: center;
          justify-content: center;
  -webkit-transition: all 0.2s ease;
  transition: all 0.2s ease;
  font: 15px sans-serif;
  font-weight: 300;
  text-shadow: 0 0 20px #fff;
  text-transform: uppercase;
  -webkit-animation: breath2 0.8s linear 10ms infinite alternate;
          animation: breath2 0.8s linear 10ms infinite alternate;
  cursor: pointer;
  margin-top: 10px;
  text-decoration: none;
}

.button:before {
  content: "";
  display: block;
  width: calc(100% - 10px);
  height: calc(50px - 8px);
  left: 5px;
  top: 3px;
  position: absolute;
  background-color: transparent;
  border: 1px solid #fff;
  border-radius: var(--border-radius-before);
}

.button.fire {
  border-color: #ffeca8;
  background-image: -webkit-gradient(linear, left top, left bottom, from(rgba(255, 138, 48, 0.6)), to(rgba(240, 96, 29, 0.6)));
  background-image: linear-gradient(to bottom, rgba(255, 138, 48, 0.6), rgba(240, 96, 29, 0.6));
  -webkit-box-shadow: 0 0 0px rgba(255, 138, 48, 0.6), 0 0px 3px rgba(240, 96, 29, 0.6), inset 0 1px #ffeca8, inset 0 -1px #ffeca8;
          box-shadow: 0 0 0px rgba(255, 138, 48, 0.6), 0 0px 3px rgba(240, 96, 29, 0.6), inset 0 1px #ffeca8, inset 0 -1px #ffeca8;
  color: #ffeca8;
}

.button.fire::before {
  -webkit-box-shadow: inset 0 0 20px #ffeca8;
          box-shadow: inset 0 0 20px #ffeca8;
}

.button.ice {
  border-color: #a8ecff;
  background-image: -webkit-gradient(linear, left top, left bottom, from(rgba(48, 138, 255, 0.6)), to(rgba(29, 96, 240, 0.6)));
  background-image: linear-gradient(to bottom, rgba(48, 138, 255, 0.6), rgba(29, 96, 240, 0.6));
  -webkit-box-shadow: 0 0 0px rgba(48, 138, 255, 0.6), 0 0px 3px rgba(29, 96, 240, 0.6), inset 0 1px #a8ecff, inset 0 -1px #a8ecff;
          box-shadow: 0 0 0px rgba(48, 138, 255, 0.6), 0 0px 3px rgba(29, 96, 240, 0.6), inset 0 1px #a8ecff, inset 0 -1px #a8ecff;
  color: #a8ecff;
}

.button.ice::before {
  -webkit-box-shadow: inset 0 0 20px #a8ecff;
          box-shadow: inset 0 0 20px #a8ecff;
}

.button.blaze {
  border-color: #ffa8a8;
  background-image: -webkit-gradient(linear, left top, left bottom, from(rgba(156, 20, 20, 0.6)), to(rgba(240, 29, 29, 0.6)));
  background-image: linear-gradient(to bottom, rgba(156, 20, 20, 0.6), rgba(240, 29, 29, 0.6));
  -webkit-box-shadow: 0 0 0px rgba(156, 20, 20, 0.6), 0 0px 3px rgba(240, 29, 29, 0.6), inset 0 1px #ffa8a8, inset 0 -1px #ffa8a8;
          box-shadow: 0 0 0px rgba(156, 20, 20, 0.6), 0 0px 3px rgba(240, 29, 29, 0.6), inset 0 1px #ffa8a8, inset 0 -1px #ffa8a8;
  color: #ffa8a8;
}

.button.blaze::before {
  -webkit-box-shadow: inset 0 0 20px #ffa8a8;
          box-shadow: inset 0 0 20px #ffa8a8;
}

.button.nature {
  border-color: #b7ffa8;
  background-image: -webkit-gradient(linear, left top, left bottom, from(rgba(9, 134, 15, 0.6)), to(rgba(36, 240, 29, 0.6)));
  background-image: linear-gradient(to bottom, rgba(9, 134, 15, 0.6), rgba(36, 240, 29, 0.6));
  -webkit-box-shadow: 0 0 0px rgba(9, 134, 15, 0.6), 0 0px 3px rgba(36, 240, 29, 0.6), inset 0 1px #b7ffa8, inset 0 -1px #b7ffa8;
          box-shadow: 0 0 0px rgba(9, 134, 15, 0.6), 0 0px 3px rgba(36, 240, 29, 0.6), inset 0 1px #b7ffa8, inset 0 -1px #b7ffa8;
  color: #b7ffa8;
}

.button.nature::before {
  -webkit-box-shadow: inset 0 0 20px #b7ffa8;
          box-shadow: inset 0 0 20px #b7ffa8;
}

.button:hover {
  text-decoration: none;
}

.button:hover.fire {
  -webkit-box-shadow: 0 0 10px rgba(255, 138, 48, 0.8), inset 0 1px #ffeca8, inset 0 -1px #ffeca8;
          box-shadow: 0 0 10px rgba(255, 138, 48, 0.8), inset 0 1px #ffeca8, inset 0 -1px #ffeca8;
}

.button:hover.fire:before {
  -webkit-box-shadow: inset 0 0 50px 0 #ffeca8;
          box-shadow: inset 0 0 50px 0 #ffeca8;
}

.button:hover.ice {
  -webkit-box-shadow: 0 0 10px rgba(48, 138, 255, 0.8), inset 0 1px #a8ecff, inset 0 -1px #a8ecff;
          box-shadow: 0 0 10px rgba(48, 138, 255, 0.8), inset 0 1px #a8ecff, inset 0 -1px #a8ecff;
}

.button:hover.ice:before {
  -webkit-box-shadow: inset 0 0 50px 0 #a8ecff;
          box-shadow: inset 0 0 50px 0 #a8ecff;
}

.button:hover.blaze {
  -webkit-box-shadow: 0 0 10px rgba(156, 20, 20, 0.8), inset 0 1px #ffa8a8, inset 0 -1px #ffa8a8;
          box-shadow: 0 0 10px rgba(156, 20, 20, 0.8), inset 0 1px #ffa8a8, inset 0 -1px #ffa8a8;
}

.button:hover.blaze:before {
  -webkit-box-shadow: inset 0 0 50px 0 #ffa8a8;
          box-shadow: inset 0 0 50px 0 #ffa8a8;
}

.button:hover.nature {
  -webkit-box-shadow: 0 0 10px rgba(9, 134, 15, 0.8), inset 0 1px #b7ffa8, inset 0 -1px #b7ffa8;
          box-shadow: 0 0 10px rgba(9, 134, 15, 0.8), inset 0 1px #b7ffa8, inset 0 -1px #b7ffa8;
}

.button:hover.nature:before {
  -webkit-box-shadow: inset 0 0 50px 0 #b7ffa8;
          box-shadow: inset 0 0 50px 0 #b7ffa8;
}

.button:hover + .button:hover {
  margin-top: 15px;
  -webkit-animation-delay: 0.3s;
          animation-delay: 0.3s;
}

.breathingMain {
  -webkit-animation: breath2 2s 0.5s infinite alternate;
          animation: breath2 2s 0.5s infinite alternate;
}

@-webkit-keyframes breath {
  0% {
    -webkit-transform: scaleX(1);
            transform: scaleX(1);
  }
  100% {
    -webkit-transform: scaleX(0.95);
            transform: scaleX(0.95);
  }
}

@keyframes breath {
  0% {
    -webkit-transform: scaleX(1);
            transform: scaleX(1);
  }
  100% {
    -webkit-transform: scaleX(0.95);
            transform: scaleX(0.95);
  }
}

.test {
  -webkit-animation: breath2 0.8s linear 10ms infinite alternate;
          animation: breath2 0.8s linear 10ms infinite alternate;
}

@-webkit-keyframes breath2 {
  0% {
    -webkit-transform: skewX(0.1deg) scaleX(1) translateY(-10px);
            transform: skewX(0.1deg) scaleX(1) translateY(-10px);
  }
  100% {
    -webkit-transform: skewX(0.1deg) scaleX(0.95) translateY(10px);
            transform: skewX(0.1deg) scaleX(0.95) translateY(10px);
  }
}

@keyframes breath2 {
  0% {
    -webkit-transform: skewX(0.1deg) scaleX(1) translateY(-10px);
            transform: skewX(0.1deg) scaleX(1) translateY(-10px);
  }
  100% {
    -webkit-transform: skewX(0.1deg) scaleX(0.95) translateY(10px);
            transform: skewX(0.1deg) scaleX(0.95) translateY(10px);
  }
}

@-webkit-keyframes breath2_orig {
  0% {
    -webkit-transform: skewX(-10deg) scaleX(1);
            transform: skewX(-10deg) scaleX(1);
  }
  100% {
    -webkit-transform: skewX(-10deg) scaleX(0.95);
            transform: skewX(-10deg) scaleX(0.95);
  }
}

@keyframes breath2_orig {
  0% {
    -webkit-transform: skewX(-10deg) scaleX(1);
            transform: skewX(-10deg) scaleX(1);
  }
  100% {
    -webkit-transform: skewX(-10deg) scaleX(0.95);
            transform: skewX(-10deg) scaleX(0.95);
  }
}
/*# sourceMappingURL=buttons.css.map */
<div class="container">
  <button class="button ice">Button</button>
</div>

Sorry for the long snippet (my first contribution :) )

Dit answered 14/8, 2021 at 14:8 Comment(1)
I was having stuttering animations on Firefox as well, but the skewX(0.1deg) fixes it strangely enough. Thanks for posting your solution here!Astraea
B
1

I am using keyframes with box-shadow to create an animation. Then, I am using the animation command to select the keyframe name and define some detailes on the animation (duration, delay etc...).

#myanimation{
  animation: x 1s 1 ease-out ;
  -webkit-animation: x 1s 1 ;
  -webkit-backface-visibility: hidden;
  -moz-animation: x 1s 1;
  -o-animation: x 1s 1 ;
}

I will not post my keyframe, because its long. However, even though my animation duration is only 1 seconds, I am experiencing lags. I tried everything to fix the lags, I added linear,ease-in-out etc.. all kinds of tags to the animation commnad but unsuccessful.

At the end, I just

deactivated the add-ons

(since add-ons also reduce the performance of firefox especially add-ons that block add-ons). After deactivating all my add-ons, it worked perfectly.

Brisbane answered 31/1, 2018 at 11:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.