Share Posted December 10, 2020 Reproduction steps: 1. Open the official demo attached in a new window 2. Scroll to the orange section saying "TWO" 2. Resize the window a significant amount After the resize and refresh complete, ScrollTrigger will snap to a section different than the one prior to the resize. What's an elegant way to fix this? See the Pen KKpLdWW by GreenSock (@GreenSock) on CodePen Link to comment Share on other sites More sharing options...
Solution Solution Share Posted December 11, 2020 Hey CityLights and welcome to the GreenSock forums. To fix this you'll need to record which section is snapped to each time that it snaps. Then on refresh you should set the scroll position to the value it needs to be to have that section at the top of the viewport. 2 1 Link to comment Share on other sites More sharing options...
Author Share Posted December 15, 2020 On 12/11/2020 at 2:33 PM, ZachSaucier said: Hey CityLights and welcome to the GreenSock forums. To fix this you'll need to record which section is snapped to each time that it snaps. Then on refresh you should set the scroll position to the value it needs to be to have that section at the top of the viewport. Thanks for the simple scenario-specific solution which leverages the snapping sections. How would you go about this if there was no snapping behavior and the user could stop their scroll position at intermediate points between the sections? Link to comment Share on other sites More sharing options...
Share Posted December 15, 2020 11 minutes ago, CityLights said: How would you go about this if there was no snapping behavior and the user could stop their scroll position at intermediate points between the sections? You could use the progress of the ScrollTrigger to do similar calculations. 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