Jump to content
Search Community

Animate svg with gradient

redmile test
Moderator Tag

Go to solution Solved by Jonathan,

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 redmile, and welcome to the GreenSock forum!

 

You can try and use a staggerTo() tween along with the special cycle property to animate a SVG gradient

 

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

 

It will stagger through all of the SVG <linearGradient> <stop> elements.

 

It uses the GSAP cycle property which is only available for stagger tweens

 

  • Like 2
Link to comment
Share on other sites

  • Solution

try this redmile:

 

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

 

also i used this online SVG cleanup tool to optimize your SVG code (dont forgot to un-toggle Clean ID's)

 

https://jakearchibald.github.io/svgomg/

 

read this GreenSock article on using the cycle property with stagger tweens:

 

http://greensock.com/gsap-1-18-0

 

keep in mind that the gradient <stops> elements you have are all the same color, if you change their starting values it will animate the color better.

 

:)

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...