Jump to content
Search Community

Animating Gradient Offset Values

Jerbach test
Moderator Tag

Go to solution Solved by GreenSock,

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

First off, I love this library and have been using it forever! Just took the plunge on a membership to support your efforts. Now on to the problem.


I'm trying to animate the offset values of a gradient but I'm not able to for some reason? I successfully used the same method to animate stopColor, but no dice on offset. I've tried using a few methods but the example is using cycle. What am I doing wrong here?


Please see the codepen below:

See the Pen PzBXxa by Jerbach (@Jerbach) on CodePen

Link to comment
Share on other sites

  • Solution

Welcome! Nice to hear from a long-time user. 


It looks like the problem is twofold: 

  1. "offset" is an attribute. Thus, you need to use the AttrPlugin
  2. The cycling doesn't work in a nested fashion, like inside the AttrPlugin. But that's easy to work around (see demo below)

Here's a forked version that seems to work. I just use a function-based value to spit back the appropriate value. 



Does that help?

  • Like 4
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...