原生javascript实现图片滚动、延时加载功能(2)

}
        },
        isLoad:function(src,n){
            var src = src,
                n = n,
                o_img = new Image(),
                _that = this;
            o_img.onload = (function(n){
                _that.oImg[n].setAttribute('src',src);
                _that.oImg[n].removeAttribute(_that.sHolder_src);
            })(n);
            o_img.src = src;

},
        int:function(){
            this.loadImg();
            var _that = this,
                timer = null;
            // 滚动:添加定时器,防止频繁调用loadImg函数
            window.onscroll = function(){
                clearTimeout(timer);
                timer = setTimeout(function(){
                    _that.loadImg();
                },100);
            }
        }
    }

效果图:

原生javascript实现图片滚动、延时加载功能

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wgxgyf.html