glem1337 Posted October 8, 2020 Share Posted October 8, 2020 Hello! I am new to GSAP. I have to implement a slider like this https://drive.google.com/file/d/1vQy5BA_RY1u4EITYKgsDgLKdowihtSnP/view How can I remove the white space under the slider so that the slider is visually between the content? And simulate a longer scroll in order to set the duration of the scene? That is, after the slider has opened, I will need time to animate the slides. P. S. Sorry for my English. I just teach him. I hope you understand me. See the Pen bGeGLWY by glem1337 (@glem1337) on CodePen Link to comment Share on other sites More sharing options...
ZachSaucier Posted October 8, 2020 Share Posted October 8, 2020 Hey glem1337 and welcome to the GreenSock forums. 20 minutes ago, glem1337 said: How can I remove the white space under the slider so that the slider is visually between the content? And simulate a longer scroll in order to set the duration of the scene? That is, after the slider has opened, I will need time to animate the slides. To do that I recommend that you create a container around the image and all of the content after it and then pin that container. That way the content that follows it stays pinned for that duration but there's no space between the image and the rest of the content. 24 minutes ago, glem1337 said: simulate a longer scroll in order to set the duration of the scene? We talk about that in the ScrollTrigger docs Link to comment Share on other sites More sharing options...
glem1337 Posted October 8, 2020 Author Share Posted October 8, 2020 1 hour ago, ZachSaucier said: Hey glem1337 and welcome to the GreenSock forums. To do that I recommend that you create a container around the image and all of the content after it and then pin that container. That way the content that follows it stays pinned for that duration but there's no space between the image and the rest of the content. We talk about that in the ScrollTrigger docs Thanks for the answers. These solutions work. But if the slider is at the bottom and there is no content after it? In this case, I will not be able to apply this approach. At the moment, I got it like this, but for some reason the content jerks on pin. Link to comment Share on other sites More sharing options...
ZachSaucier Posted October 8, 2020 Share Posted October 8, 2020 27 minutes ago, glem1337 said: I got it like this, but for some reason the content jerks on pin. That's actually because of the margin-top on your h2 at the top (it moves the <body> down the page). I recommend removing it and using padding instead. I also recommend that you don't manually calculate the offset position. Doing so won't update on resize the way you have it. Just let ScrollTrigger do the calculation for you: See the Pen abZzmdV?editors=0010 by GreenSock (@GreenSock) on CodePen Link to comment Share on other sites More sharing options...
glem1337 Posted October 9, 2020 Author Share Posted October 9, 2020 Thanks for the help. Result: Link to comment Share on other sites More sharing options...
glem1337 Posted October 10, 2020 Author Share Posted October 10, 2020 I have one more question. How can I make the block decrease at the end work the same way as the increase at the start. I mean is that the decrease at the end starts before the dashed line disappears and the parallax ends. At the moment, the decrease at the end begins only after the end of the parallax and the hiding of the line. I found a solution, but I'm not sure it is correct. tween .to( ".scroll-slider", { clipPath: "inset(10% 5%)", duration: 1 }, "start" ) .to( ".scroll-progress-line", { y: "-100%", duration: 4 }, "start" ) .to( ".scroll-slider-item img", { y: "-20%", duration: 4 }, "start" ) .to( ".scroll-slider", { clipPath: "inset(20% 10%)", duration: 1 }, "-=1" // this solution ); Also I would like to know if it seems to me that the animation at the end is slower? And how to solve it. Link to comment Share on other sites More sharing options...
ZachSaucier Posted October 10, 2020 Share Posted October 10, 2020 25 minutes ago, glem1337 said: I found a solution, but I'm not sure it is correct. Yep, a negative offset is probably the best solution 26 minutes ago, glem1337 said: it seems to me that the animation at the end is slower? And how to solve it. That's due to the animation's ease. By default animations use an out ease which is slower at the end. If you want no ease, use ease: "none" on the relevant tween. You can see other eases in the ease docs. Link to comment Share on other sites More sharing options...
glem1337 Posted October 10, 2020 Author Share Posted October 10, 2020 Thanks a lot! 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