繁体   English   中英

延迟加载图像将加载页面上的所有图像

[英]lazy load images loads the all images on page

我正在使用bttrlazyloading插件将所有图像延迟加载到页面上。 我有一个包含div的列表,每个div内都有一个图像。

我的内容是动态的,并且使用模板(html)克隆div,具体取决于我需要多少元素。

这是我的代码:

    $.each ( THIS.get('content').topics, function(i, topic){
                $('.topic_list').append($('#topic_item').clone(true).attr('id','topic_item'+i));
                $('#topic_item'+i).find('.topic_image').attr('id', 'topic_image_'+i);
                $('#topic_image_'+i).attr('data-bttrlazyloading-xs-src', topic.icons.high_res_icon_180x180);
                $('#topic_image_'+i).attr('data-bttrlazyloading-sm-src', topic.icons.high_res_icon_180x180);
                $('#topic_image_'+i).attr('data-bttrlazyloading-md-src', topic.icons.high_res_icon_360x360);
                $('#topic_image_'+i).attr('data-bttrlazyloading-lg-src', topic.icons.high_res_icon_360x360);
});

当我完成构建页面时,我会调用插件:

$('.topic_image').bttrlazyloading({
            backgroundcolor: 'transparent',
            animation: 'fadeInUp',
            event: 'scroll'
        })

在我滚动到图像之前,图像不会显示,我的问题是,即使您仍然看不到它们,图标也会一次全部加载。

我可以在网络上看到。

我该如何解决?

不能相信..很多小时后..我错过了<!DOCTYPE html>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM