fisshy / react-scroll

React scroll component
https://github.com/fisshy/react-scroll/blob/master/README.md
MIT License
4.36k stars 437 forks source link

dynamic spy value #427

Open marslan2037 opened 4 years ago

marslan2037 commented 4 years ago

I have a site where i have menu and submenu when menu item is clicked that have submenu, spy={true} works correctly when user scroll. But the issue is I have each section under if else condition, means when one menu item is clicked, display property for it will be true and other sections will hide. Everything is working correctly but I have little issue with spy property. When page load first time menu item is already displaying and first menu item is also true now when I click on second menu item it correctly take me to that section and highlight that menu and its submenu first element but submenu of first element is still have active class, it should not have active class because that section is not displaying. Can i add spy propertly dynamically so when second menu item is true spy property for submenu of first menu item become false ?

here you can see it live: https://testmystorespeed.herokuapp.com/5ecdcd99afbaa5001c297164

fisshy commented 4 years ago

I think I understand the problem.

Couldn't you just override the active class if that section isnt active?

Our could you just rerender that section if that section wasnt active, so it would refresh that section.

Do the Links point to the same element?

Would be easier for me to help you, If I could see a plunkr demonstrating the issue.