ssaruh Posted January 26, 2023 Share Posted January 26, 2023 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 More sharing options...
Rodrigo Posted January 26, 2023 Share Posted January 26, 2023 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! 1 Link to comment Share on other sites More sharing options...
ssaruh Posted January 27, 2023 Author Share Posted January 27, 2023 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 2 Link to comment Share on other sites More sharing options...
AntonioNB4 Posted June 9, 2023 Share Posted June 9, 2023 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 ? Link to comment Share on other sites More sharing options...
GSAP Helper Posted June 9, 2023 Share Posted June 9, 2023 @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. 1 Link to comment Share on other sites More sharing options...
Rodrigo Posted June 9, 2023 Share Posted June 9, 2023 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! 1 Link to comment Share on other sites More sharing options...
AntonioNB4 Posted June 9, 2023 Share Posted June 9, 2023 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 More sharing options...
Rodrigo Posted June 9, 2023 Share Posted June 9, 2023 Hi, You can fork this codepen that has all the plugins already loaded: See the Pen aYYOdN by GreenSock (@GreenSock) on CodePen Happy Tweening! Link to comment Share on other sites More sharing options...
AntonioNB4 Posted June 9, 2023 Share Posted June 9, 2023 See the Pen KKrwOjP by Antonio-Nocella (@Antonio-Nocella) on CodePen In the horizontal scroll sticky here is it possible to decrease the scroll speed ? And can I block the panels that scroll a few pixels before reaching the edge of the previous panel? Link to comment Share on other sites More sharing options...
rad3 Posted February 6 Share Posted February 6 Hello, how is this example written with rtl? body, html { direction: rtl; } Because it doesn't work with rtl And the photo cannot be zoomed with scale See the Pen gOEKQYp by meysamrad (@meysamrad) on CodePen Link to comment Share on other sites More sharing options...
GreenSock Posted February 6 Share Posted February 6 Are you trying to do something like this?: See the Pen RwdJqVW?editors=0010 by GreenSock (@GreenSock) on CodePen Link to comment Share on other sites More sharing options...
rad3 Posted February 6 Share Posted February 6 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 More sharing options...
GreenSock Posted February 6 Share Posted February 6 You mean the transform origin? transformOrigin: "right center" See the Pen abMKPPp?editors=1010 by GreenSock (@GreenSock) on CodePen 1 Link to comment Share on other sites More sharing options...
rad3 Posted February 6 Share Posted February 6 9 minutes ago, GreenSock said: You mean the transform origin? transformOrigin: "right center" thank you Link to comment Share on other sites More sharing options...
rad3 Posted February 24 Share Posted February 24 On 2/6/2024 at 10:44 AM, mey3am said: thank you I changed the panel to width: 100%; But it does not display the last slide or panel See the Pen gOEKQYp by meysamrad (@meysamrad) on CodePen Link to comment Share on other sites More sharing options...
mvaneijgen Posted February 24 Share Posted February 24 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 More sharing options...
rad3 Posted February 25 Share Posted February 25 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 More sharing options...
mvaneijgen Posted February 25 Share Posted February 25 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 More sharing options...
rad3 Posted February 26 Share Posted February 26 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 More sharing options...
mvaneijgen Posted February 26 Share Posted February 26 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now