Jump to content
GreenSock

ssaruh

Horizontal Scroll with Sticky Panels Effect

Recommended Posts

Hi! I'm trying to achieve an effect similar to https://gallery.delivery/ or https://shadow-brand.com/, where there is horizontal scrolling but the sections stick to the left side of the page so that the next section overlaps it.

 

 

Here is my pen:

 

I've achieved the horizontal scrolling effect looking at other threads here, but not sure how to approach the stickiness aspect-- I've tried applying a class that would fix the position of the panels but that removes them from the flow and causes things to jump around. Are you able to horizontally pin each element as it reaches the left side of the screen? Haven't seen any examples of this. Not expecting anyone to solve the whole thing for me but if anyone could point me in the right direction or could suggest a method of doing this it would be super helpful!

 

Thanks!

 

 

See the Pen dyjeLYG by ssaruuuu (@ssaruuuu) on CodePen

Link to comment
Share on other sites

Hi @ssaruh and welcome to the GreenSock forums!

 

This is more related to the way the elements are animated. In this case you have to move each card it's own width times the card's index in the collection and the duration of each animation has to increase based on the same index. For that you can use function based values:

let scrollTween = gsap.to(sections, {
  xPercent: (i) => -100 * i,
  duration: (i) => 0.5 * i,
  ease: "none", // <-- IMPORTANT!
  scrollTrigger: {
    trigger: ".container",
    pin: true,
    markers: true,
    scrub: 0.1,
    //snap: directionalSnap(1 / (sections.length - 1)),
    end: "+=3000 bottom"
  }
});

Unfortunately the container animation class toggle functionality goes a bit wonky and it doesn't work as expected:

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

 

You'll have to come up with a different custom logic to toggle that class, based on the progress of the ScrollTrigger instance on scrollTween. I tinkered with it quite a bit and couldn't come up with something solid and I don't have a lot of time to go through this right now.

 

Let us know if you have more questions.

Happy Tweening!

Link to comment
Share on other sites

Thank you so much! This achieved the main effect I was looking for.

 

The only other thing I added was a conditional statement so that the last panel doesn't scroll all the way to the left, + making it responsive so it switches to a vertical scroll under 767px window.

See the Pen YzjvNXB by ssaruuuu (@ssaruuuu) on CodePen

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