I'm trying to display and immediately animate a rotation of a SVG element using a CSS transition.
const node = getSVGElement(); // Has 'transform' set to 'rotate(0)'
node.classList.add('svg-animation');
const parent = document.getElementById('someDiv');
parent.appendChild(node);
setTimeout(() => {
node.setAttribute('transform', `rotate(${someOtherValue})`);
}
}, 50);
And in CSS:
.svg-animation {
transition: transform 0.5s ease-in-out;
}
This works as intended in Chrome, but Firefox and Safari display the element without animating it at all. Is there a different syntax (or method) that should be used so that it works in these browsers (I don't care about IE)?