Jump to content
GreenSock

gmw

Setting SVG fill on TimelineMax

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

Perfect PointC!!! Thank you!

 

For anyone reading this, you may find this very helpful info:

 

  • Like 2
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.
×