Jump to content

Search In
  • More options...
Find results that contain...
Find results in...

Create Scroll Trigger demo in React

Recommended Posts

Hello All,

Please can someone help me convert this codepen to react. I tried to remove some of the fluff (like the loader and some css) but it seems the scroll animation freezes halfway through after my changes. Specifically, I would like to also get this demo to work without including

document.body.style.overflow = "auto";



See the Pen BaogqYy by noeldelgado (@noeldelgado) on CodePen

Link to comment
Share on other sites



Adding a start point to your ScrollTrigger instances seems to work:

  { x },
    x: xEnd,
    scrollTrigger: {
      trigger: section,
      start: "top 92%",
      scrub: 0.5

Also it's a good idea to pass an array of dependencies to your useEffect hook in order to prevent it from running everytime the state or  a property of the component is updated:

useEffect(() => {
  // code here
}, []);

The array can have dependencies or not, read more about it here:



Happy Tweening!!!

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