简体   繁体   中英

Fill not applying to SVG using vivus.js

Hey guys i have the following SVG drawing animation using vivus.js SEE HERE , the svg is below:

<style type="text/css">
  .st0 {
    fill: transparent;
    stroke: #020000;
    stroke-miterlimit: 10;
  }

</style>

<path id="XMLID_3_" class="st0" d="M-0.5,3.5H19c0,0,1.5-0.1,1.5,1.6V77c0,0,1,1.1,2,0V4c0,0,0-1.5,1.4-1.3l20.4,0c0,0,8,0.1,12,8.7
                S54.9,31.6,42,32.9l0.1,2.8c0,0,20.8,0.5,20.1,19.8c0,0-0.1,16.5-19.6,19.5v3c0,0,14.5-0.3,19-10.4c0,0,13-22.6-10-32.9V34
                c0,0,9.8-5.3,9.1-15.6c0,0,0.5-8.8-7.4-15l8.1-0.1l0.4,38L62,75.9c0,0,1.6,1.2,3.2-0.1s0-73.3,0-73.3h22.3V76c0,0,3.1,2.1,4.3-0.1
                s0-73.4,0-73.4H104c0,0,9.5,1.8,9.5,11.1V76c0,0,1.6,2.1,3.5,0s0-66.1,0-66.1s-2.5-9.4-16-9.4H-0.5V3.5z" />

I am using the following JS to animate the svg:

new Vivus('svglogo', {duration: 200} , function() {
    $('#svglogo st0').attr({'fill' : '#020000'})
});

Now after the drawing is complete i would like to add the fill to the logo and so i have the following in the callback function:

$('#svglogo st0').attr({'fill' : '#020000'})

But this really does't seem to work, can somebody tell me what am i doing wrong here ? why is the fill not applying ? I'd really like to apply the fill once the drawing animation is complete .

The fill property set by CSS style overrules the fill attribute. You should be using

$('#svglogo st0').css({'fill' : '#020000'})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM