console
window.onscroll = scroll;
function scroll()
{
let height = 3000 - document.querySelector('html').clientHeight;
let temp;
if (window.pageYOffset < height/3) temp = 1;
else if (window.pageYOffset < height/3*2) temp = 2;
else if (window.pageYOffset < height/3*3) temp = 3;
console.log(temp);
}
<body>
<div id="id1">
<div class="class1 yellow">xxxx</div>
<div class="class1 green">123</div>
</div>
</body>
html {
height: 100vh;
width: 100vw;
}
body {
height: 3000px;
width: 100vw;
background: red;
min-width: 500px;
margin: 0;
}
#id1 {
position: fixed;
height: 100vh;
background: blue;
width: 100vw;
}
.class1 {
width: 100%;
height: 50%;
}
.yellow {
background: yellow;
}
.green {
background: green;
}