Share Posted August 26, 2020 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 More sharing options...
Share Posted August 26, 2020 Hi Matteo, you need to create an array of refs, currently only the last item is animated. Checkout this guide on how to create an array of refs and then animate them. Hope that helps. 3 Link to comment Share on other sites More sharing options...
Share Posted August 26, 2020 https://codesandbox.io/s/distracted-flower-xp8wk?file=/src/App.js 2 Link to comment Share on other sites More sharing options...
Author Share Posted August 26, 2020 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now