Shumais Posted December 5, 2022 Share Posted December 5, 2022 Hey, I'm trying to create an accordion similar to this one. I want the first row to be open initially and the rest of the rows open as the user starts scrolling, i was thinking of triggering active classes, but don't seem to find a method to do that. Thank You in advance! See the Pen ExLWYVL by GreenSock (@GreenSock) on CodePen Link to comment Share on other sites More sharing options...
mvaneijgen Posted December 5, 2022 Share Posted December 5, 2022 Hi @Shumais welcome to the forum! Can you maybe share what you've already tried, that way we can see your thought process and better help you understand GSAP. Even a pen that doesn't work is a great starting point! Link to comment Share on other sites More sharing options...
Shumais Posted December 5, 2022 Author Share Posted December 5, 2022 Hi @mvaneijgen, I am developing a website for a client and there is a section where i want to open the accordion on scroll with the initial one open. Here is the link for the codepen. See the Pen oNyJGxo by rrichie551 (@rrichie551) on CodePen I'm using scrolltrigger for the functionality, but can't wrap my head around on how ill trigger 'active' class on scroll using scrolltrigger. Thank You in Advance!! Link to comment Share on other sites More sharing options...
mvaneijgen Posted December 6, 2022 Share Posted December 6, 2022 The best thing to do with ScrollTrigger is to remove it! This seems counter intuitive, but ScrollTrigger is just animating something on scroll, so just focus on the animation at first and only when you're happy with the animation add ScrollTrigger back in. So that's what I did for your pen at the moment. This way I can focus on the animation at first, right now I've build it in a for loop, but maybe it's better to just write the whole timeline by hand if you want custom logic per item, but this would be the general idea, just toggle the classes onStart and onComplete. Hope it helps and happy tweening! See the Pen bGKOZzW?editors=0010 by mvaneijgen (@mvaneijgen) on CodePen I took some logic form the following video by our @Carl which is a really smart way to work with staggers 1 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