Skip to content
Advertisement

Inline SVG css animation not working on Safari

I’m using the latest version of these:

JavaScript

This is the CSS I am using to achieve the desired CSS animation effects across literally all browsers except Safari.

JavaScript

The grow-divider animation works perfectly, and another irrelevant one works perfectly as well on a different page. The only one I cannot get to work only on Safari is the grow-buttons animation. Yes Safari in general I’ve back-tested every version made in the past 5 years it does exactly the same thing..

Initially I thought it was a CSS naming problem… no I’ve tried multiple implementations of CSS for compatibility to no avail. I then thought it was just Safari, it could be, but why are my other CSS animations working then? I even put my CSS on the newly generated element via JS and it doesn’t work. I even used async programming in JQuery to make sure the CSS wasn’t applied before the <i> was changed to <svg> It’s worth mentioning that the CSS classes on the original <i> element are injected into the new <svg> from font-awesome… so the CSS animation is inherited.. this logic works on all browsers except Safari… I have absolutely no idea what is causing it, anyway here’s the html for the entire page:

JavaScript

I think I could get it to work if I just yanked my own svg and put it neatly in an <img> and didn’t do some masking magic on my buttons.. I don’t want to do that because that’ll cut off a ton of features of fontawesome and take more time… so in the meantime I have the animation turned off for Safari users and it’s sad because I want this animation it’s incredibly satisfying and I really don’t want to have to bake my own masked SVGs and put them in a <img> just so I can run CSS animations over SVGs… I mean.. is that what I have to do?

Can I inject inline SVG into a src?

Here’s the baked SVG data from fontawesome after the page loads (I took out the data:)

JavaScript

Advertisement

Answer

Wow….. really hope this helps someone…

To fix the problem you use regular old css to transform scale it in the animation.

Font-size can be used to scale up inline SVGs on all browsers except Safari

JavaScript

Bottom line:

Use transform: scale() instead of font-size: ()px on SVG CSS animations to maximize compatibility.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement