Jump to content
Search Community

Using fixed sections with ScrollTrigger in combination with anchor links

spearquit test
Moderator Tag

Go to solution Solved by Rodrigo,

Recommended Posts

Hi all,

 

I’ve slightly modified a Codepen demo that runs as fixed full page sections:

 

 

The sections work how I’d like – but I’m a bit stumped on getting anchor links with ScrollToPlugin to scroll to sections (preferably dynamically). I may just be entirely the wrong setup approach using fixed sections as there's nothing to anchor to,  but it’d be great to find out if I could get ScrollTo to work with it.

 

I’ve scratched around looking at ST demos that feature anchors / menus, ie

See the Pen MzWzyv, by PointC (@PointC) on CodePen

See the Pen qBbmLr, by bassta (@bassta) on CodePen

See the Pen bGVjLwG, by GreenSock (@GreenSock) on CodePen

but I can’t see how these solutions could apply to fixed sections. 

 

Any thoughts, approaches or help would be hugely appreciated.

 

Thanks again,

 


 

See the Pen VwBKMLN by spearquit (@spearquit) on CodePen

Link to comment
Share on other sites

Oh wow, yeah, that’s exactly what I was looking to do. Thankyou @Jack & @Rodrigo, really appreciated. 

 

I had planned on turning the nav into a timeline that indicates what section you’re on as you scroll through them. I had thought onToggle / adding classes,  similar to this ScrollTrigger demo:

See the Pen bGVjLwG by GreenSock (@GreenSock) on CodePen

would be the approach. But I guess being fixed means it’s not going to know where to add it anyway? Unsure what could work within GSAP here.

 

I’m wondering how this could be achieved here? Slightly updated pen:

See the Pen GRBNZwo by spearquit (@spearquit) on CodePen

Link to comment
Share on other sites

  • Solution

Hi,

 

Maybe something like this:

See the Pen rNrWrXN by GreenSock (@GreenSock) on CodePen

 

There is no need to use a bunch of methods and other ScrollTrigger instances for that, just use the ones you already created for the panels and use the index on that loop and the event callbacks ScrollTrigger has in order to add/remove the active class.

 

Hopefully that helps. Let us know if you have more questions.

 

Happy Tweening!

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