Clou Posted May 31, 2023 Share Posted May 31, 2023 Hi! i cant figure out why, when the accordion is opened (marketing heading click), the horizontal scroll (orange cards) are pushed down out of the middle of the screen, but when its not opened the position is correct. See the Pen bGmPqQg by peva92 (@peva92) on CodePen Link to comment Share on other sites More sharing options...
Solution GreenSock Posted May 31, 2023 Solution Share Posted May 31, 2023 That's because you're fundamentally changing the layout/positioning of everything by opening/closing that accordion. Remember that ScrollTrigger pre-calculates the start/end positions for all ScrollTriggers so that it's extremely performant while scrolling. So for example, let's say that trigger for the horizontal section is calculated to start at a scroll position of 500...but then you open the accordion which PUSHES everything down by 100px. Well now that start position should be adjusted to be 600 instead of 500. All you need to do is force ScrollTrigger to refresh all of its calculations by putting ScrollTrigger.refresh() in your onComplete: See the Pen VwEJyaV?editors=0010 by GreenSock (@GreenSock) on CodePen 1 Link to comment Share on other sites More sharing options...
Clou Posted June 1, 2023 Author Share Posted June 1, 2023 Of course... thank you!! 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