Share Posted August 15, 2022 I have horizontal slider initiated using GSAP. But the problem is when horizontally scrolled it triggers other section too. What I wanted is that the sections below horizontal scroll to be only triggered when come to the original position. Also I want the whole document to be pinned. Is it possible to do with GSAP? As always I am very hopeful to you guys. Thanks in advance. See the Pen BarqbaY?editors=1111 by devSanjay (@devSanjay) on CodePen Link to comment Share on other sites More sharing options...
Share Posted August 15, 2022 Hi there! Thanks for the clear demo - appreciated. How about something like this. Using the previous scrollTriggers end point as the starting point for the next one? See the Pen GRxYebY by GreenSock (@GreenSock) on CodePen 1 Link to comment Share on other sites More sharing options...
Author Share Posted August 15, 2022 Thankyou @Cassie for your reply. But the solution that you provided won't work if there comes another section in between those two sections. Link to comment Share on other sites More sharing options...
Solution Solution Share Posted August 16, 2022 Hi @codeSanjay. You just forgot to set the pinnedContainer value: See the Pen jOzQqRK?editors=1010 by GreenSock (@GreenSock) on CodePen The ScrollTrigger needs to know that you're pinning the container so that it can offset the start/end values accordingly. Does that clear things up? 1 Link to comment Share on other sites More sharing options...
Author Share Posted August 16, 2022 Thankyou @GreenSock . Your solution perfectly fits for my problem. But the container of horizontal sliders behave weirdly on enterBack condition. It doesn't fire as soon as it meets the condition but fires later on. Is there a way to fix it? See the Pen wvmYOvm?editors=1010 by devSanjay (@devSanjay) on CodePen Link to comment Share on other sites More sharing options...
Share Posted August 16, 2022 I don't understand what you mean. You set the trigger to ".horizontal-sliders" and you didn't set an "end", so it uses the default of "right left", meaning when that trigger's right side hits the left side of the screen (or the equivalent distance). Sorry, I'm just not clear on what you're expecting or what you think is wrong. Link to comment Share on other sites More sharing options...
Author Share Posted August 16, 2022 @GreenSockI just wanted my horizontal sliders bg color to be changed on enter back. But as you can see it only changes at first slide. Like you said I also kept the end value. But still not working. See the Pen BarGZNm?editors=0010 by devSanjay (@devSanjay) on CodePen Link to comment Share on other sites More sharing options...
Share Posted August 16, 2022 If you only want the color to change on enter back you can use a callback? onEnterBack: () => { gsap.to('.horizontal-sliders', { backgroundColor: "red", }) } 2 Link to comment Share on other sites More sharing options...
Author Share Posted August 16, 2022 Thanks @Cassie, running gsap tween inside onEnterBack solved it. 1 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