DannyA12 Posted August 12, 2020 Share Posted August 12, 2020 Hello! There's probably a very simple solution to this, but how can I pin/unpin a background (or section) while animating an element using ScrollTrigger? I want the scrollbar to act like a scrubber for the element that is being animated (using a timeline with multiple tweens) and then have the background unpinned as soon as the element is done animating. I have set the background and element as values to the trigger and the endTrigger, respectively, with the proper start/end values, but as soon as I add a second tween to the timeline, the scrollbar stops scrubbing with the animation. Thank you so much! Link to comment Share on other sites More sharing options...
ZachSaucier Posted August 12, 2020 Share Posted August 12, 2020 Hey Danny and welcome to the GreenSock forums. It's hard to say given the lack of code or a demo. My guess is that you have a timeline with a tween and you're applying a ScrollTrigger to that tween? Like this? gsap.timeline() .to('.foo', { scrollTrigger: { ... } }) If so, don't do that It doesn't make much sense. Instead, you should apply the ScrollTrigger to the timeline itself in most cases. See this post for how to create a minimal demo: Link to comment Share on other sites More sharing options...
DannyA12 Posted August 12, 2020 Author Share Posted August 12, 2020 Hi Zach, Thanks for the quick response. Here's a minimal CodePen demo. See the Pen eYZJJZK by USCDanny12 (@USCDanny12) on CodePen When building out the demo, I realized that my endTrigger was incorrect. Now the scrollbar is linked to the animation (very embarrassing). If the syntax looks off, I'm more than happy to update anything. In any case, thank you for your help and fast response. 2 Link to comment Share on other sites More sharing options...
ZachSaucier Posted August 12, 2020 Share Posted August 12, 2020 That's one of the many benefits of making a minimal demo! Good work figuring it out 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