So basically my CSS animation is supposed to emulate some text being typed, un-typed and finally changed to another word. Normally the CSS keyframe and JavaScript setInterval are in sync but on mobile devices they sometimes get out of sync or if I go to a new tab they de-synchronize.
<center style="display: flex; width:70vw">
<h1 style="padding-right:20px;">We</h1>
<h1 id="terminal-text">innovate.</h1>
</center>
<script type="text/javascript">
var i = 0;
words = ['architect.','build.','design.','code.','develop.','innovate.'];
setInterval(function() {
$("#terminal-text").text(words[i]);
i++;
if (i > words.length) {
i=0;
}
},3000);
</script>
#header .banner h1 {
margin: 1em 0 .5em -10%;
padding: 0;
color: white;
text-align: left;
}
@keyframes terminal {
0% {max-width:0}
50% {max-width:100%}
55% {max-width:100%}
100% {max-width:0}
}
#header #terminal-text {
font-weight: bold;
margin: 1em 0 .5em 0;
padding: 0;
animation: terminal 3s infinite;
overflow: hidden;
white-space: nowrap;
border-right: 4px solid white;
text-align: left;
}