Jump to content
Search Community

Staggered Accordion With The First Row Open

Shumais test
Moderator Tag

Recommended Posts

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

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 

 

 

  • Like 1
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.
×
×
  • Create New...