Jump to content
GreenSock

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

Unable to animate SVG

Recommended Posts

Hi @Vinod :)

 

Welcome to the forum.

 

You'll need to use 'x' instead of 'left' with your SVG and 'fill' instead of 'color'. Your distance of 524 will also be outside the viewBox. Please try this:

TweenLite.to(logo, 2, {x:100, fill:"black"});

 

Hopefully that helps, Happy tweening.

:)

 

  • Like 4
  • Thanks 1
Link to comment
Share on other sites

Hi and welcome to the GreenSock forums,

 

Thanks for the demo. Very helpful.

An important thing to keep in mind is that you can only animate properties that the browsers and various CSS and SVG specifications allow you to.

 

The target of your tween is an svg <path> and paths don't have left or color properties.

 

In your demo, try adding this css:

 

#lettere {
  color:black;
  left:100px;
}

 

You will notice that it won't have any affect on the svg path.

 

However you can change the position of a path by applying a css transform like transform:translateX(100px); to do that in GSAP you would just animate the x value.  To change the color of a path you would animate it's fill

 

var logo = document.getElementById("lettere");
TweenLite.to(logo, 2, {x:100, fill:"black"});

 

See the Pen dejOLK?editors=0010 by GreenSock (@GreenSock) on CodePen

 

  • Like 4
  • Thanks 1
Link to comment
Share on other sites

4 minutes ago, PointC said:

Hi @Vinod :)

 

Welcome to the forum.

 

You'll need to use 'x' instead of 'left' with your SVG and 'fill' instead of 'color'. Your distance of 524 will also be outside the viewBox. Please try this:


TweenLite.to(logo, 2, {x:100, fill:"black"});

 

Hopefully that helps, Happy tweening.

:)

 

Thanks @PointC that helped.

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.

×