Jump to content
Search Community

Issues Animating Elements of SVG

dxc test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hello dxc, and Welcome to the Greensock Forum!


Since you are explicitly trying to animate the height attribute.. you need to add that height  within the attr:{} object


Codepen example:

See the Pen BFpmx by jonathan (@jonathan) on CodePen

// animates the css property height
TweenLite.to(svgAll, 1.5, {height:250});

// animates the height attribute with attr: {} object
TweenLite.to(rect01, 1.5, {attr:{height:5}});


When animating attributes, GSAP uses the AttrPlugin:




Below is taken from AttrPlugin Docs:


Tweens any numeric attribute of a DOM element. For example, let's say your DOM element looks like this:

<rect id="rect" fill="none" x="0" y="0" width="500" height="400"></rect>


You could tween the "x", "y", "width", or "height" attributes using AttrPlugin like this:

TweenLite.to("#rect", 1, {attr:{x:100, y:50, width:100, height:100}, ease:Linear.easeNone});


You can tween an unlimited number of attributes simultaneously. Just use the associated property name inside the attr:{} object.

AttrPlugin is NOT intended to be used with css-related properties because the CSSPlugin already handles those.


Note: a common mistake is to forget to wrap attributes in a attr:{} object which is essential for specifying your intent.


Does that help? :)

  • 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.
  • Create New...