Jump to content
Search Community

Animate text color according to moving background (container) animation

zlogicalape test
Moderator Tag

Go to solution Solved by PointC,

Recommended Posts

I'm using ScrollTrigger along with 2 animations:
1- A text color change

2- A background (just a container) moving from right to left.

I'm trying to make it seem like whenever the background reaches the text, the text's color starts to change along with the movement of the background.

I've seen an example of this that layers two containers with the same text each (in the same fixed position).
I didn't like this approach much and wanted to try one with the same text that has an animation on it, as show in the Codepen example.

I am unable to make one animation dependent on the other so that they move together and eventually just brute forced the different values for the duration & offset to make it work a bit (but doesn't on different screens)

Is there a way to make one move with the other or maybe even independent from the duration ?!

See the Pen ZErvYVd by zlogicalape (@zlogicalape) on CodePen

Link to comment
Share on other sites

3 hours ago, PointC said:

If you don't want to use two elements, it sounds like a good use case for CSS variables.

 

 

 

 

Happy tweening.

 

 


I believe this is exactly what I'm looking for.
Don't know much about CSS variables but I'm looking into them now.
Thanks a lot, this looks perfect <3

Cheers

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