Jump to content
Search Community

ScrollTrigger detect backwards scrolling.

mso web agency test
Moderator Tag

Recommended Posts

I'm trying to create a Background colour changing animation based on data attributes from a section. I have the base logic in place however it doesn't seem to work backwards. The idea is that as a section scrolls into view the background colour would change and stay like that until the endTrigger. Although i tried doing this with a single scrollTrigger but couldn't quite get it right, However this method kind of works going forwards but it's wrong backwards.

The logic isn't quite right but if anyone could point me in the correct direction that would be appreciated!

See the Pen f1a3751119bc3c7ce6139991efd6cbc8 by msoweb (@msoweb) on CodePen

Link to comment
Share on other sites

Also, just a heads up but safari is really struggling recently to paint big changes like this. I tried a few weeks ago and whole sections of the page were chunked out on scroll 🫠

 

I'd suggest using fixed divs and doing opacity fades instead of targeting background color.

See the Pen 4a679cfaa6f8a96bd83bceaea0fa01b4?editors=1010 by cassie-codes (@cassie-codes) on CodePen

  • 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.
×
×
  • Create New...