Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SVG animation is not working on IE11

I have a really simple loading animation that works perfectly on Firefox and Chrome, but in IE11 it's not showing the SVG figure.

Here is the full example: JSFiddle sample

SVG:

<svg class="circular-loader" viewBox="25 25 50 50">   <circle class="loader-path" cx="50" cy="50" r="20" fill="none" stroke-width="2" stroke-miterlimit="10"/> </svg> 

The animation, which is a rotation, is working on IE11, but the SVG, which is a circle, is not being displayed.

Any idea?

I just can't figure out what is not being supported by IE11.

like image 488
Pablo Avatar asked Nov 19 '15 19:11

Pablo


People also ask

Why is my SVG not animating?

One of the most common reasons why the SVG animation doesn't work is the use of <img> tags to add the SVG. The SVG might be visible on the website, but the animation will not start. You can easily fix this by replacing all <img> tags with an <object> tag.

Can you animate SVG files?

You can also make simple animations without having to add another JavaScript library to your website's page load. In this article, we'll learn how to create lightweight, scalable animations using SVGs with CSS. Although we'll use Sass for the demos, CSS will also work.

How do I make an SVG animation?

How it create SVG Animations: Select the Frame you want to animate and click on Enable SVG Export. Select a node within that Frame to set up animations such as X Position, Y Position, Scale, Rotation and Opacity. Use the built-in live-preview to tweak your animations until you're happy with the result.


2 Answers

Only Microsoft Edge will support SVG CSS Transitions and Animation.. especially stroke-dasharray.

Please see the Microsoft Developer Docs:

https://dev.windows.com/en-us/microsoft-edge/platform/status/csstransitionsanimationsforsvgelements

Allows CSS Transitions and Animations to apply to SVG elements.
Unprefixed version: Microsoft Edge build 10240+

As you can see in my fork of your example. You were not seeing the loader spin due to not having the stroke attribute on your circle element.

https://jsfiddle.net/z8w4vuau/50/

You can see how it can spin now. But you will have to check if the browser is IE and adjust your stroke-dasharray so it is larger dash. Since IE11 and below do not support animating SVG stroke-dasharray and stroke-dashoffset with CSS animation or transitions, unless it is Microsoft Edge build 10240+.

But if you need a cross browser solution to animate SVG, especially stroke-dasharray and stroke-dashoffset, then look into using a JS animation library like the GreenSock Animation Platform (GSAP). Using the DrawSVGPlugin

https://greensock.com/drawSVG

like image 97
Jonathan Marzullo Avatar answered Sep 29 '22 16:09

Jonathan Marzullo


IE does not support CSS animation of SVG elements. It also doesn't support the standard built-in SMIL animations that SVG has.

If you convert your animation to native SVG animations, you could perhaps get it working using the FakeSmile library. Otherwise you will need to use some alternative fallback for IE - such as an animated gif or something.

like image 35
Paul LeBeau Avatar answered Sep 29 '22 15:09

Paul LeBeau