newGsapMember Posted October 23, 2025 Posted October 23, 2025 Hello, I have a sticky menu on the left that adjusts based on the height of the content. I’m also using an accordion on the page. However, when an accordion item expands and the content becomes longer, the left sticky menu does not update its position and remains stuck at the top. How can I fix this issue so the sticky menu recalculates and stays aligned with the content height changes? See the Pen ogbdLNQ by ozenccam (@ozenccam) on CodePen.
Solution Rodrigo Posted October 23, 2025 Solution Posted October 23, 2025 Hi, You're looking to use the refresh method after the accordion animation completes and the reverse is completed: const tween = gsap.from(accordion_content, { height: 0, duration: 0.3, ease: "power1.inOut", reversed: true, onComplete: () => st.refresh(), onReverseComplete: () => st.refresh(), }); Also since you have the ScrollTrigger instance stored in a constant you can use the refresh method of the specific ScrollTrigger instance, maybe is not needed to call the global refresh method that refreshes all the ScrollTrigger instances in the page, which can be expensive. Here is a fork of your demo: See the Pen RNryROa by GreenSock (@GreenSock) on CodePen. Hopefully this helps Happy Tweening!
newGsapMember Posted October 23, 2025 Author Posted October 23, 2025 Thank you so much for your help. The issue has been resolved. 1
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