Skip to content
Advertisement

Tag: svg

How to get svg icon as a string from a .svg file

Is there a way to get svg icon as a string while you have the .svg file with JavaScript ? To be more clear, I need a function which does: Answer You can use the fetch() function. The function svgFileToString() will not return anything, but you can replace console.log(text); with whatever. For the example I’m using a data URL to

SVG stroke animation not working in Safari

My JS code goes over each path, and adds a stroke-dasharray and stroke-dashoffset according to path length: Then, My CSS just animates the dashoffset to 0, while lowering the stroke opacity and raising the fill opacity: This works perfectly in Chrome – the animation shows the paths being drawn, but in Safari, the paths just show up without any animation.

svg stroke-dashoffset animation with percentage values

I have been successful in animating stroke-dashoffset with value as <length> as folllowing However, I am trying to figure out how can I calculate the exact % value in css if I decide to use <percentage> instead of value. I came to know from this post that percentages are calculated in respect to the current viewport, which I tried as

Best way to include reusable SVG in React

I am including SVG as reusable component on my react application. Sample of SVG component is as follows On page level, I am importing IconComponent and reusing it. Is there any other best way to include reusable SVGs in React pages which improves performance/page load? Answer 1. SVG with webpack command line webpack.config.js then 2. SVG as component also you

Advertisement