<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
.container{
width: 1100px;
margin: 0 auto;
}
.test_model{
height: 300px;
width: 300px;
margin-top: 1200px;
background-color: red;
margin-bottom: 600px;
}
</style>
</head>
<body>
<div class="container">
<div class="test_model" id="model"></div>
</div>
<script type="text/javascript">
window.onload = function(){
var obs = new IntersectionObserver((changes)=>{
changes.forEach(change => console.log(change.intersectionRatio.toFixed(1)))
},{
threshold:[.2,.3,.5,.7,1]
});
obs.observe(document.getElementById('model'));
};
</script>
</body>
</html>