Jump to content
Search Community

Setting SVG fill on TimelineMax

gmw 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

Sorry, I realize that there are a lot of tweens in my GSAP code. Any help would be greatly appreciated. 

 

I am running a master timeline with 2 nested timelines (tl1 and tl2). On my inline SVG I have the following default fill colors

<path id="left-face" fill="#FFC8B4" ...
<path id="right-face" fill="#DBB0A5" ...

All I want to do is change those colors for the entire duration of the second timeline only (e.g. tl2). Afterwards they will return to the defaults.#FFC8B4 and #DBB0A5

 //tl2.set( leftFace, {fill: 'green'}, "-=1")
 //tl2.set( rightFace, {fill: 'silver'}, "-=1")
 tl2.to( leftFace, 0, {fill: 'green'}, "-=1")
 tl2.to( rightFace, 0, {fill: 'silver'}, "-=1")

When I did this, the fill colors for leftFace and rightFace also changed (to green and silver - overriding the defaults #FFC8B4 and #DBB0A5) on the first timeline (tl1)

//tl1.set( leftFace, {fill: '#FFC8B4'}, "-=1")
//tl1.set( rightFace, {fill: '#DBB0A5'}, "-=1")
tl1.to( leftFace, 0, {fill: '#FFC8B4'}, "-=1")
tl1.to( rightFace, 0, {fill: '#DBB0A5'}, "-=1") 

What is even more perplexing is that on the second iteration of the master timeline, the colors are set correctly from there on in.

 

Again any help at all would be greatly appreciated. Thank you.

 

 

 

 

 

 

 

See the Pen YWAyvb by gmw (@gmw) on CodePen

Link to comment
Share on other sites

Hi gmw :)

 

If you change lines 57 and 58 to these, I think you'll get the outcome you'd like:

tl2.set( leftFace,  {fill: 'green', immediateRender:false},0)
tl2.set( rightFace,  {fill: 'silver', immediateRender:false},0)

Hopefully that helps.

 

Happy tweening.

:)

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