问答详情
源自:2-5 onscroll事件实现瀑布流布局的图片加载功能

Unable to get property 'offsetTop' of undefined or null reference

他报这个问题
function checkscrollside(){
    var oParent=document.getElementById('main');
    var aPin=getByClass(oParent,'pin');
    var lastPinH=aPin[aPin.length-1].offsetTop+Math.floor(aPin[aPin.length-1].offsetHeight/2);
    var scrollTop=document.documentElement.scrollTop||document.body.scrollTop;
    var documentH=document.documentElement.clientHeight;//页面高度
    return (lastPinH<scrollTop+documentH)?true:false;//到达指定高度后 返回true,触发waterfall()函数
}

提问者:慕粉3398298 2016-07-05 01:14

个回答

  • Boringlife
    2016-07-05 09:49:47

    function check(){
       var oPraent=document.getElementById('main');
       var oBox=getByClass(oPraent,'box');
       var lastBOxH=oBox[oBoxs.length-1].offsetTop+Math.floor(oBoxs[oBoxs.length-1].offsetHeight/2);
       var scrollTop=document.body.scrollTop || document.documentElement.scrollTop;
       var height=document.body.clientHeight || document.documentElement.clientHeight;
       return (lastBOxH<scrollTop+height)?true:false;
    }