I need to trigger a div to scale down using the CSS scale transform after a few seconds via JavaScript. I've tried toggling a class or setting the CSS manually but either approach is causing a flicker on my iPhone iOS 11 on Safari or Chrome.
The red div first very quickly jumps to the final scale, then back again, and then animates correctly.
On Chrome and Safari on desktop it animates perfectly smoothly.
https://jsfiddle.net/2fy3acup/6/
HTML
<div id="title">
Hello
</div>
CSS
#title {
background: red;
transform: scale(1);
transition: transform 1s;
}
#title.smaller {
transform: scale(0.3);
}
JS
setTimeout(function() {
// Glitches on mobile webkit
//document.getElementById("title").classList.add("smaller");
// Also glitches on mobile webkit
document.getElementById("title").style.transform = 'scale(0.4)';
}, 1000);
Am I doing something wrong?