Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
cbourne

Animating SVG, changing fill and stroke

Recommended Posts

Hi,

 

I've embedded my base64 encoded SVG into my CSS but the fill and stroke tweens seem to be ignored. See the Codepen example.

 

What am I doing thats wrong?

 

Here's the SVG

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 125.368 104.307"><path fill="#8F5E8D" d="M85.194 86.885v17.422l4.494-5.123c4.84 5.1 4.8 5.1 4.8 5.123V86.885c-1.302 1.04-2.898 1.38-4.52 1.38-1.555.035-3.168-.365-4.768-1.38zm4.813-15c-3.536 0-6.754 3.403-6.754 7.175 0 3.7 3.2 7.1 6.8 7.1s6.755-3.405 6.755-7.15C96.762 75.3 93.5 71.9 90 71.885zm27.657 12.635c.313 0 .95-.364.95-1.04s-.637-1.013-.95-1.013h-15.106c-.637 0-1.276.337-1.276 1.014 0 .7.6 1 1.3 1 15.082.02 15.118.02 15.118.04zm-15.106 5.8h15.1c.313 0 .95-.704.95-1.38 0-.338-.637-1.014-.95-1.014h-15.106c-.637 0-1.276.676-1.276 1 .005.674.624 1.374 1.324 1.393zm22.497-17.76C110.91 57.9 110.9 57.9 110.9 57.895c-.325-.34-.638-.677-.962-.677H94.835c-3.535 0-6.114 3.066-6.114 6.81v3.096c0 .7.6 1.4 1.3 1.4.67 0 1.31-.676 1.31-1.354v-3.095c0-2.026 1.596-3.744 3.536-3.744h13.5v8.53c0 3.7 2.6 6.8 6.1 6.818h8v22.2c0 2.055-1.275 3.405-3.19 3.405H102.55c-.638 0-1.277.703-1.277 1.717 0 .7.6 1.4 1.3 1.4h16.7c3.533 0 6.084-2.73 6.084-6.5V73.69c.014-.39.046-.79-.254-1.13zm-10.613 0c-1.912 0-3.532-1.69-3.532-3.743v-6.812c9.964 10.6 10 10.6 10 10.555h-6.468zM48.872.252C22.494 13.6 22.5 13.6 22.5 13.565h57.6L53.366.3C52.09-.084 50.146-.084 48.9.252zM22.176 104.307h57.9v-89.39H22.19v89.39zm40.523-81.2c3.53 0 6.4 3.1 6.4 6.812 0 3.43-2.878 6.5-6.41 6.5s-6.44-3.07-6.44-6.508c.01-3.718 2.944-6.818 6.444-6.81zm0 19.786c3.53 0 6.4 3.1 6.4 6.8 0 3.435-2.878 6.5-6.41 6.5s-6.44-3.065-6.44-6.5c.01-3.693 2.945-6.793 6.445-6.8zm0 19.807c3.53 0 6.4 3.1 6.4 6.476 0 3.77-2.878 6.838-6.41 6.838s-6.44-3.067-6.44-6.838c.012-3.476 2.95-6.476 6.45-6.496zm0 20.104c3.53 0 6.4 3.1 6.4 6.474 0 3.77-2.878 6.84-6.41 6.8s-6.44-3.067-6.44-6.84c.01-3.338 2.945-6.438 6.445-6.433zM39.54 23.107c3.534 0 6.4 3.1 6.4 6.8 0 3.434-2.9 6.5-6.436 6.5-3.22 0-6.116-3.066-6.116-6.5.035-3.707 2.912-6.807 6.112-6.8zm0 19.793c3.534 0 6.4 3.1 6.4 6.812 0 3.435-2.9 6.5-6.436 6.5-3.22 0-6.116-3.065-6.116-6.5C33.423 46 36.3 42.9 39.5 42.892zm0 19.78c3.534 0 6.4 3.1 6.4 6.475 0 3.77-2.9 6.838-6.436 6.8-3.22 0-6.116-3.067-6.116-6.838C33.423 65.7 36.3 62.7 39.5 62.68zm0 20.124c3.534 0 6.4 3.1 6.4 6.5 0 3.77-2.9 6.84-6.436 6.84-3.22 0-6.116-3.068-6.116-6.84.035-3.404 2.912-6.504 6.112-6.5zM0 104.307h18.6V35.04H0v69.267zm9.333-61.414c3.19 0 6.1 3.1 6.1 6.812 0 3.435-2.9 6.5-6.09 6.5-3.536 0-6.435-3.065-6.435-6.5C2.898 46 5.8 42.9 9.3 42.893zm0 19.786c3.19 0 6.1 2.7 6.1 6.47 0 3.403-2.9 6.473-6.09 6.5-3.536 0-6.435-3.07-6.435-6.475-.01-3.78 2.892-6.48 6.392-6.5zm0 20.12c3.19 0 6.1 3.1 6.1 6.8 0 3.432-2.9 6.5-6.09 6.5-3.536 0-6.435-3.068-6.435-6.5-.01-3.7 2.892-6.8 6.392-6.8z" /></svg>

See the Pen WbvBqE by carlskii (@carlskii) on CodePen

Edited by cbourne
Link to comment
Share on other sites

Thanks, just tried that. So my SVG is not base64 encoded. I'm still not getting the fill and stroke tweens though.

Link to comment
Share on other sites

Michael was right - if you don't include the SVG as an element in the DOM, the nodes inside the svg aren't added to the DOM and can't be accessed or modified. See 

See the Pen ogXrqx by jamiejefferson (@jamiejefferson) on CodePen

 

If you want to use the SVG as a background-image in CSS you won't be able to tween its children.

  • Like 3
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×