2

I've an issue with transform/translation glitches within an animation. The errors occur exclusively within Mozilla, obviously, but are functioning in Chrome. I realize that this is a repeated issue, so I first did some research at CSS3 and MDN, reviewed these questions, and ensured for the functionality of transform here. With that in tow, I remain confused.

body {
  overflow: hidden;
  background: #e8e8e8;
}

.floor {
  height: 90px;
  width: 450px;
  border-bottom: 1px solid #e8e8e8;
  position: absolute;
  top: 50%;
  left: 50%;
  margin-top: -50px;
  margin-left: -250px;
}

.box {
  box-sizing: border-box;
  width: 90px;
  height: 90px;
  border-radius: 2px;
  background: #d0d0d0;
    -webkit-transform-origin: 100% 100%;
    -moz-transform-origin: 100% 100%;
    -o-transform-origin: 100% 100%;
    transform-origin: 100% 100%;
    -webkit-animation: turnMove 3500ms infinite alternate cubic-bezier(0.75, 0, 0.175, 1);
    -moz-animation: turnMove 3500ms infinite alternate cubic-bezier(0.75, 0, 0.175, 1);
    -o-animation: turnMove 3500ms infinite alternate cubic-bezier(0.75, 0, 0.175, 1);
    animation: turnMove 3500ms infinite alternate cubic-bezier(0.75, 0, 0.175, 1);
    animation-play-state: play;
    animation-delay: 0ms;
}

@keyframes turnMove {
  0% {
    transform: translate(0, 0) rotate(0turn);
    transform-origin: 100% 100%;
  }
  25% {
    transform: translate(0, 0) rotate(0.25turn);
    transform-origin: 100% 100%;
    animation-timing-function: step-end;
    background: #b9b9b9;
  }
  25.01% {
    transform: translate(90px, 90px) rotate(0.25turn);
    transform-origin: 100% 0;
    background: #b9b9b9;
  }
  50% {
    transform: translate(90px, 90px) rotate(0.5turn);
    transform-origin: 100% 0;
    animation-timing-function: step-end;
    background: #a2a2a2;
  }
  50.01% {
    transform: translate(270px, 90px) rotate(0.5turn);
    transform-origin: 0 0;
    background: #a2a2a2;
  }
  75% {
    transform: translate(270px, 90px) rotate(0.75turn);
    transform-origin: 0 0;
    animation-timing-function: step-end;
    background: #8b8b8b;
  }
  75.01% {
    transform: translate(360px, 0) rotate(0.75turn);
    transform-origin: 0 100%;
    background: #8b8b8b;
  }
  100% {
    transform: translate(360px, 0) rotate(1turn);
    transform-origin: 0 100%;
    background: #747474;
  }
}

@-webkit-keyframes turnMove {
  0% {
    transform: translate(0, 0) rotate(0turn);
    transform-origin: 100% 100%;
  }
  25% {
    transform: translate(0, 0) rotate(0.25turn);
    transform-origin: 100% 100%;
    animation-timing-function: step-end;
    background: #b9b9b9;
  }
  25.01% {
    transform: translate(90px, 90px) rotate(0.25turn);
    transform-origin: 100% 0;
    background: #b9b9b9;
  }
  50% {
    transform: translate(90px, 90px) rotate(0.5turn);
    transform-origin: 100% 0;
    animation-timing-function: step-end;
    background: #a2a2a2;
  }
  50.01% {
    transform: translate(270px, 90px) rotate(0.5turn);
    transform-origin: 0 0;
    background: #a2a2a2;
  }
  75% {
    transform: translate(270px, 90px) rotate(0.75turn);
    transform-origin: 0 0;
    animation-timing-function: step-end;
    background: #8b8b8b;
  }
  75.01% {
    transform: translate(360px, 0) rotate(0.75turn);
    transform-origin: 0 100%;
    background: #8b8b8b;
  }
  100% {
    transform: translate(360px, 0) rotate(1turn);
    transform-origin: 0 100%;
    background: #747474;
  }
}

@-moz-keyframes turnMove {
  0% {
    transform: translate(0, 0) rotate(0turn);
    transform-origin: 100% 100%;
  }
  25% {
    transform: translate(0, 0) rotate(0.25turn);
    transform-origin: 100% 100%;
    animation-timing-function: step-end;
    background: #b9b9b9;
  }
  25.01% {
    transform: translate(90px, 90px) rotate(0.25turn);
    transform-origin: 100% 0;
    background: #b9b9b9;
  }
  50% {
    transform: translate(90px, 90px) rotate(0.5turn);
    transform-origin: 100% 0;
    animation-timing-function: step-end;
    background: #a2a2a2;
  }
  50.01% {
    transform: translate(270px, 90px) rotate(0.5turn);
    transform-origin: 0 0;
    background: #a2a2a2;
  }
  75% {
    transform: translate(270px, 90px) rotate(0.75turn);
    transform-origin: 0 0;
    animation-timing-function: step-end;
    background: #8b8b8b;
  }
  75.01% {
    transform: translate(360px, 0) rotate(0.75turn);
    transform-origin: 0 100%;
    background: #8b8b8b;
  }
  100% {
    transform: translate(360px, 0) rotate(1turn);
    transform-origin: 0 100%;
    background: #747474;
  }
}
<div class="floor">
    <div class="box"></div>
</div>

Here too is the codepen.

As you can see (and as far as my knowledge can allow), I've included the -moz- prefix before keyframes and transformations where necessary (if necessary). However, with each translation/turn of the box, the box will first translate a great distance from its intended location, return, then resume the animation until it repeats this error on the next translation/turn. It appears as a rapid glitch, visible only for a frame or two.

I thought at first that it may be due to how I parsed the percentages of the keyframes, or perhaps a miscommunication of the utilized transform short-hand, but, after testing, I still cannot say for sure. I've not found any alteration of the code that might alter the error or smooth it at any step.

As the animation plays smoothly in Chrome, I would like it also to do so in Mozilla. Any assistance on this matter would be greatly appreciated.

Community
  • 1
  • 1
zzz
  • 123
  • 1
  • 9
  • 1
    FYI you don't need to prefix `animation`, `keyframes`, or `transform-origin` for Firefox. They've worked unprefixed since about October of 2012, *25* versions ago. Likewise Chrome has supported them for a while unprefixed, too, for about 10 or 15 major versions. – TylerH Jun 01 '16 at 21:45
  • But `transform-origin` is known to be buggy in Firefox. Possibly related: http://stackoverflow.com/questions/19179758/css3-transform-difference-in-firefox-and-chrome-and-ie – TylerH Jun 01 '16 at 21:55
  • Just to piggyback on what @TylerH said, you can always check this site for information on appropriate prefixes: http://shouldiprefix.com/ – ghost_dad Jun 01 '16 at 22:01
  • @TylerH Appreciate the thought! I actually noticed this fact when first investigating my issue via the second, linked stack-question. This snippet was how my code was written prior to discovering this, however, and, as it seems to do no harm, I did not feel motivated to alter it quite yet. Again, thank you for the confirmation. – zzz Jun 01 '16 at 22:38
  • Always check [Can I Use](http://caniuse.com/#feat=transforms2d) – T04435 Jun 01 '16 at 22:47
  • @T04435 OP mentioned that he checked caniuse in his question. – TylerH Jun 01 '16 at 23:06

0 Answers0