Jump to content
Search Community

Scroll a sidebar with viewport but pin to top or bottom

Ambient.Impact test
Moderator Tag

Go to solution Solved by akapowl,

Recommended Posts

Hi there. I've been looking at the ScrollTrigger plug-in to solve a UX problem but can't seem to get it working. I essentially want a sidebar, when taller than the viewport, to scroll along with the page both up and down, until its bottom edge comes up and hits the bottom edge of the viewport which then causes it to behave as fixed. The same should happen when you scroll upwards and the top of the sidebar comes down and hits the top edge of the viewport.

 

Here's a crude diagram that might help visualize things. The content column is red, the sidebar yellow, and the viewport is black. In this case it's scrolling downwards, so just reverse it (or flip it upside down?) for scrolling upwards.

 

proxy_scroll.thumb.png.1ece974c7f6e602b55fd1d707675dd46.png

 

In the attached pen, I'm only attempting this with the left (first) sidebar.

See the Pen ZExGVxM by ambient-impact (@ambient-impact) on CodePen

Link to comment
Share on other sites

  • Solution

Welcome to the GSAP forum!

 

I'm not sure I fully understand the exact behaviour you are aiming for, but this sounds a lot like what was handled in this older thread.

 

 

 

 

Here's a direct link to the helper function crafted by @GreenSock, posted within that thread. I hope that will help. Happy tweening!

 

  • Like 1
  • Thanks 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...