1 window.onscroll=function () { 2 var sTop=document.body.scrollTop; 3 var WH=document.body.clientHeight; 4 var con=document.getElementById(‘con‘); 5 var dTop=con.offsetTop; 6 7 if (sTop>=dTop-(WH-100)) { 8 //执行动画 9 }; 10 }
时间: 2024-10-26 10:29:42
1 window.onscroll=function () { 2 var sTop=document.body.scrollTop; 3 var WH=document.body.clientHeight; 4 var con=document.getElementById(‘con‘); 5 var dTop=con.offsetTop; 6 7 if (sTop>=dTop-(WH-100)) { 8 //执行动画 9 }; 10 }