Background:
So I’ve read a bunch of different articles and stack overflows on CSS3 Animations not working on Safari, etc. I’ve attempted several of those examples such as adding the prefix -webkit- making keyframes 0% to 100%, and even transform:translate3d(0,0,0) to trigger hardware acceleration. I’ve even tried adding a delay as someone suggested but is not in the current JSFiddle. Nothing has worked so far but I am sure it’s a minor thing I am missing.
Question
CSS Animations are not my strong suit but any reason why my circle is jumping to the end of the keyframes vs showing a sweeping effect across the bar in an infinite animation on my iPhone Safari/WKWebView? It works on my Windows device with Chrome/Edge.
Code
// CSS
@-webkit-keyframes ios-sweep-test {
0% {
cx: 5;
}
100% {
cx: 100%;
}
}
@keyframes sweep {
from {
cx: 5;
}
to {
cx: 100%;
}
}
circle {
animation-duration: 3s;
animation-timing-function: ease-in-out;
animation-name: sweep;
animation-iteration-count: infinite;
animation-direction: alternate;
transform:translate3d(0, 0, 0)
-webkit-animation-duration: 3s;
-webkit-animation-timing-function: ease-in-out;
-webkit-animation-name: ios-sweep-test;
-webkit-animation-iteration-count: infinite;
-webkit-animation-direction: alternate;
-webkit-transform: translate3d(0, 0, 0);
}
// HTML
<svg width="100%" height="20px">
<g transform="translate(0,10)">
<rect width="100%" height="2" y="-1" x="0" stroke="green" />
<circle r="4" cx="5" stroke="rgb(0, 0, 0)" fill="rgb(255, 255, 255)" />
</g>
</svg>
JSFiddle
https://jsfiddle.net/2btz19qL/2/
Image
2
Answers
In order to get the sweeping animation to transition properly in my example for Safari browser and mobile device I was able to do the following.
https://jsfiddle.net/1hys3rqb/
Two things I changed to make it work in Safari:
transform:translate3d(0, 0, 0)
is missing a;
which produces a CSS erroranimation-name: sweep;
is in the top section, but-webkit-animation-name: ios-sweep-test;
was set in the lower section, causing the animation to not work at all.