Jump to content
Search Community

Horizontal scroll doesnt work

mdegraaff test
Moderator Tag

Recommended Posts

Your minimal demo wasn't working at all - you might find it easier to just fork a React starter template on Stackblitz.


I did notice a few things by glancing at your code: 

  1. You were creating nested ScrollTriggers which you definitely shouldn't do. An animation's playhead cannot logically be controlled by both a parent timeline AND the scroll position (those could be going in completely different directions).
  2. You're using React but you're not doing proper cleanup. gsap.context() is your new best friend because it makes cleanup super easy in React. Please read this article:
  3. You didn't put your animation code in a useEffect() or useLayoutEffect(), so it was being called every time your component renders. That means you were probably creating a bunch of duplicated, conflicting animations/ScrollTriggers.  


If you still need help, feel free to post back here with your minimal demo and we'll do our best to jump in and help with your GSAP-specific questions. 

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