Looking at the layout, I have two sections that take up the entire page. My goal is to detect when the second section is 20% visible while scrolling, and then smoothly scroll to lock that section in place so it occupies the full space. This action should also apply to any additional sections that are added in the future.
(I am able to handle the smooth scrolling part myself).
Does anyone have any ideas on how I can achieve this functionality?
* {
margin: 0;
padding: 0;
}
#s1 {
height: 100vh;
background: red;
}
#s2 {
height: 100vh;
background: blue;
}
<section id="s1"></section>
<section id="s2"></section>