Jump to content
GreenSock

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

Staggering an Array of React Components

Recommended Posts

Hi guys.

 

I am trying to achieve an overlay menu animation using this stack: React, styled-components and gsap.

 

I made a simplified example of my code in here: https://codesandbox.io/s/young-wildflower-ld94q

 

The main overlay animation plays smoothly, but the menu items dont.

 

I am trying to create a stagger effect for each MenuItem component.

As you can see using useRef() hook only works only for the last component.

 

When Iterating an array of components useRef() is not the right choice since the same ref has been passed to multiple objects,

but still I have no idea how to get a progressive fade for each component and I'm not even sure I'm using gsap in the correct way.

 

What am I doing wrong?
Thank you in advance,
Matteo.

See the Pen by s (@s) on CodePen

Link to comment
Share on other sites

Thank you!

 

It is the first time I see this pattern. You touch me a lot.

 

Thank you so much!

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