有懂JS的会员么?
- airmarry我家买了本JS的书。。。正在吃灰中。。。
- 烂仔明JS是可以实现的,但是编码不懂
- ythu1986JS可以实现的。
具体偷懒办法:
获取鼠标滚轮事件,判断往下滚半屏幕时,加载下面三幅图。具体编码量应该不是很多。*/-12 - 新酱虽然正在学,但还不会。。。
- dominic321不懂~~~~~~
- 丁丁不懂 帮顶~
- maxwell649*/-27码农真多~~
- Berlin_Samoyet改了以后很多图都挂了,刷不出来啊,大神想想办法*/-41
- ms75738听说过··不懂··路过··
我觉得还是出去的好·· - tommylin直接关闭 开启图片延时加载 呢?
- nApoleon这个方法非常好,我已经在测试了.~
- nApoleon按照29楼的方法的确可以,但有时候如果前面的图片位置过了,就会不显示,求解决方法~
- nAxKjOTE0改成复制代码
- var offsetTop = this.getOffset(img)-500;
- if (offsetTop > document.documentElement.clientHeight && (offsetTop - scrollTop < document.documentElement.clientHeight)) {
- img.setAttribute('src', img.getAttribute('file') ? img.getAttribute('file') : img.getAttribute('src'));
- img.setAttribute('lazyloaded', true);
- }
就是前面加一段复制代码- var offsetTop1 = this.getOffset(img);
- if (offsetTop1 > document.documentElement.clientHeight && (offsetTop1 - scrollTop < document.documentElement.clientHeight)) {
- img.setAttribute('src', img.getAttribute('file') ? img.getAttribute('file') : img.getAttribute('src'));
- img.setAttribute('lazyloaded', true);
- }
- var offsetTop = this.getOffset(img)-500;
- if (offsetTop > document.documentElement.clientHeight && (offsetTop - scrollTop < document.documentElement.clientHeight)) {
- img.setAttribute('src', img.getAttribute('file') ? img.getAttribute('file') : img.getAttribute('src'));
- img.setAttribute('lazyloaded', true);
- }
- var offsetTop = this.getOffset(img)-500;
- 2008我还是自觉地出去吧。。
- nAxKjOTE065楼更新
- nApoleon解决了~高手就是厉害~
- jihang1991貌似解决了??
- nekki能不能按巴哈那麼搞?
- lilong懒加载只能缓解一下,建议考虑下使用专用的图片云服务,比如https://www.upyun.com/算下来比自己做CDN要便宜和方便
- btmen图片异步加载 其实作用不大 一般onload的时候资源都全部加载了