Jump to content
Search Community

Horizontal Scroll with Sticky Panels Effect

ssaruh test
Moderator Tag

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!

  • Like 1
Link to comment
Share on other sites

  • 4 months later...

Hello dev,
I have used the same configuration as in the demo above but I get an empty space below the container which only reduces at the end of the scroll, making the section just below appear. I don't want that empty space underneath. What could it be ?

Cattura.PNG

Link to comment
Share on other sites

@AntonioNB4 It's pretty tough to troubleshoot without a minimal demo - the issue could be caused by CSS, markup, a third party library, your browser, an external script that's totally unrelated to GSAP, etc. Would you please provide a very simple CodePen or CodeSandbox that demonstrates the issue? 

 

Please don't include your whole project. Just some colored <div> elements and the GSAP code is best (avoid frameworks if possible). See if you can recreate the issue with as few dependancies as possible. If not, incrementally add code bit by bit until it breaks. Usually people solve their own issues during this process! If not, then at least we have a reduced test case which greatly increases your chances of getting a relevant answer.

 

Here's a starter CodePen that loads all the plugins. Just click "fork" at the bottom right and make your minimal demo

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

 

If you're using something like React/Next/Vue/Nuxt or some other framework, you may find StackBlitz easier to use. We have a series of collections with different templates for you to get started on these different frameworks: React/Next/Vue/Nuxt.

 

Once we see an isolated demo, we'll do our best to jump in and help with your GSAP-specific questions. 

  • Like 1
Link to comment
Share on other sites

Hi @AntonioNB4 and welcome to the GreenSock forums!

 

Indeed without a minimal demo is really hard for us to know exactly what the issue could be.

 

Based on what you describe, you are pinning a specific container whose height is not the screen height, hence you see some separation between said container and the one right after  in the DOM.

 

In those cases is better to wrap the container of the horizontal animation and the next element in the same element and pin that particular wrapper.. Something like this:

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

 

Hopefully this helps. If you keep having issues, please create a minimal demo that clearly illustrates what's the issue you're having and where you're stuck.

Happy Tweening!

  • Like 1
Link to comment
Share on other sites

Great! Yes, that was the solution. I placed the section after within the same section where the horizontal scroll is located. I some questions: 
1) how do I upload the minimal code pen demo here ?
2) in the horizontal scroll sticky here is it possible to decrease the scroll speed ?
3) can I block the panels that scroll a few pixels before reaching the edge of the container (container start)?

 

Thanks to @Rodrigo and @GSAP Helper too.

 

Best regards.

Link to comment
Share on other sites

  • 7 months later...
1 hour ago, GreenSock said:

Are you trying to do something like this?: 

 

 

yes thank you
But I want to start the zoom not from the center, but from the right:
start: "right right",
That is correct ?

Link to comment
Share on other sites

  • 3 weeks later...

Hi @mey3am I don't know what all the calculations where doing in the xPercent and duration, when removing those the fifth panel came back. 

 

Personally I'm more a fan of creating an animation and setting that up to scroll, I've written a guide that walks you through a setup of creating a 'stacking card' effect which this could be. So if you're interested here is the link. 

 

Hope it helps and happy tweening! 

 

See the Pen xxBomJV?editors=0011 by mvaneijgen (@mvaneijgen) on CodePen

 

 

Link to comment
Share on other sites

21 hours ago, mvaneijgen said:

Hi @mey3am I don't know what all the calculations where doing in the xPercent and duration, when removing those the fifth panel came back. 

 

Personally I'm more a fan of creating an animation and setting that up to scroll, I've written a guide that walks you through a setup of creating a 'stacking card' effect which this could be. So if you're interested here is the link. 

 

Hope it helps and happy tweening! 

 

 

 

 

 

thank you very much
Now I added an image and used clipPath.
But clipPath animation doesn't work in (.panel)
I want to display the image with clipPath with scrolling animation.
Of course, I want the clipPath to work when the scrolling starts and also return to the previous state when the scrolling animation returns.

 

See the Pen gOEKQYp by meysamrad (@meysamrad) on CodePen

Link to comment
Share on other sites

Yep that is why I'm not a fan of the current setup you have. It is much easier to start with a timeline and just add all the animations to that timeline and then hook that timeline to ScrollTrigger. I strongly recommend taking look a the post I've provided. It walks you to the process how you can make any card stacking animation, even yours!

 

 

 

The issue with the current setup is that everything needs to have a strict duration otherwise things will not line up anymore, but the things you want a .panel can have like 10 animations and if you want to hack that in your current setup you have to change the whole logic just to implement that one specific thing. If you start with one timeline and just put all the animations on that timeline with one ScrollTrigger you can do what ever you want you could even restructure the whole animation half way trough and it would still all perfectly line up.

 

Take this example. Hope it helps and happy tweening! 

 

See the Pen abMbwYd?editors=0010 by mvaneijgen (@mvaneijgen) on CodePen

Link to comment
Share on other sites

16 hours ago, mvaneijgen said:

Yep that is why I'm not a fan of the current setup you have. It is much easier to start with a timeline and just add all the animations to that timeline and then hook that timeline to ScrollTrigger. I strongly recommend taking look a the post I've provided. It walks you to the process how you can make any card stacking animation, even yours!

 

 

 

The issue with the current setup is that everything needs to have a strict duration otherwise things will not line up anymore, but the things you want a .panel can have like 10 animations and if you want to hack that in your current setup you have to change the whole logic just to implement that one specific thing. If you start with one timeline and just put all the animations on that timeline with one ScrollTrigger you can do what ever you want you could even restructure the whole animation half way trough and it would still all perfectly line up.

 

Take this example. Hope it helps and happy tweening! 

 

 

 

You are right, I am trying to write like you
I want the photos to be displayed as clipPath when entering each slide
See this example
https://chryslerbuilding1930.com/
You can write like this with an example

Link to comment
Share on other sites

Hi @mey3am, yeah that looks really cool! I would start with a Codepen and just start animating the first slide how you want it and then just keep adding each next animation to the timeline, remove ScrollTrigger for now, just forces on the animation at hand. And when you are stuck post back here with what you've tried and we'll be happy to point you in the right direction. 

 

Sadly we can't create the animation for you. If you are looking for someone to build the animation for you feel free to post a question in the Jobs and freelance forum, but I'm confident that you can easily write it your self, seen all the setup you've already done. Hope it helps and 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...