Jump to content


Animating SVG's fill-opacity

Recommended Posts

Instead of animating the opacity, it seems to wait until the tween is over and then instantly jumps to the final opacity. Any thoughts on what I might be doing wrong?

See the Pen JeDLo by anon (@anon) on CodePen

Link to comment
Share on other sites

Hi dxc  :)


Since there isn't the "fill-opacity" at first  , you should create that attr , and then tween that ;

try this :

var moon = document.getElementById("moon");
TweenLite.to(moon, 1, {attr:{"fill-opacity":.5}});

or add that attr to svg path tag in html :

<path id="moon" fill="#9C2726"  fill-opacity=1 ..../>
  • Like 3
Link to comment
Share on other sites

You, Diaco, are the best. 

Link to comment
Share on other sites

  • 3 months later...
  • 1 month later...

As a follow up I'm finding that even though I declare 'fill' in the attributes this same thing is happening. I can't animate the fill (using AttributePlugin) from one colour to another. It just jumps to it at the end of the tween.


Any ideas?

  • Like 1
Link to comment
Share on other sites

Ok I just read on another post that I don't need to use the AttributePlugin. D'oh.

  • Like 1
Link to comment
Share on other sites

  • 3 years later...

For (my own) future reference, here's what works, showing that a circle's radius needs to be tweened within the attr property but stroke-width, stroke-opacity and fill-opacity (for example) don't:


<circle cx="75" cy="130" r="0" id="wave"/>
var tl = new TimelineMax({repeat:-1});
tl.to("#wave", 1, {attr:{r:100}, 'stroke-opacity': 0, 'stroke-width': 5, 'fill-opacity': 0});


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.