Jump to content
Search Community

Scrolltrigger Pin Making The Element Disappear

Samalander test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

  • Solution

It's difficult for us to work with Replit, but here's a CodeSandbox that shows it working: 

https://codesandbox.io/s/exciting-wing-cxeglt?file=/src/App.js

 

I noticed: 

  • You used useEffect() instead of useLayoutEffect() which is probably not a big deal. We just recommend useLayoutEffect() to avoid certain edge cases where React renders things prematurely leading to a flash of unstyled content. 
  • You didn't pass an empty dependency Array to the useEffect(), so it'd get called on EVERY render.
  • You didn't use gsap.context() which is super handy in React environments. Please read this article:

You don't need to use a bunch of refs, by the way. That's another benefit of gsap.context(). You can use selector text because of scoping. 

 

Does that help? 

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