MohitR Posted January 22, 2023 Share Posted January 22, 2023 How can we implement the scroll snap in a section with varying heights? See the Pen zYLRvrX by mohitrj49 (@mohitrj49) on CodePen Link to comment Share on other sites More sharing options...
Solution Cassie Posted January 22, 2023 Solution Share Posted January 22, 2023 Heya! So you'll need to pass an array with some values that represent each scroll snap point. The start of the scroll is 0 and the end is 1 - with that in mind you can calculate each point using the height of the page and the offset top of each section. Something like this - See the Pen QWBQGqp?editors=1010 by GreenSock (@GreenSock) on CodePen 2 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