shrpne / vue-inline-svg

Dynamically loads an SVG source and inline <svg> element so you can manipulate the style of it
MIT License
175 stars 21 forks source link

Animation of SVG not working #43

Closed L2k13 closed 1 year ago

L2k13 commented 1 year ago

hey,

I'm using a svg generated with svgator. The animation is in a script tag in the SVG, but the animation doesn't start.

When I put the animation in a function and call it with the @loaded prop everything works fine.

So the SVG seems fine and so does the animation.

Now I'm looking for a solution how to start the animation directly from the SVG, since the SVG is maintained in a CMS and thus I can't manually insert the animation function into the vue component and its @loaded function

Does it only work with CSS animations or does anyone have an idea?

What I have already tried is:

shrpne commented 1 year ago

Hi! VueInlinseSvg pastes svg content with innerHTML, looks like browser doesn't execute such scripts. You can use this workaround https://stackoverflow.com/a/20584396/4936667