0

我正在使用带有lazyload.js 和mCustomScrollbar的水平图像查看器

我可以让它工作,但是我不认为我的代码是正确的,并且在我可以单击、拖动或滚动滑块之前加载页面时会有延迟。

这篇文章很有帮助,但不是 100%。我相信每次滚动页面时都会重新输出代码?

我正在使用以下代码进行延迟加载:

<script>
  jQuery(function() {
    jQuery("img.lazy").lazyload({
container: jQuery("#slider"),  
skip_invisible : false,
});
jQuery(window).resize();
  });
jQuery(window).load(function() {
jQuery(window).resize();    
});
</script>

这是自定义滚动条的代码

<script>
(function($){
    $(window).load(function(){
        $("#slider").mCustomScrollbar({
axis:"x",
            scrollButtons:{
                enable:true
            },
scrollButtons:{ enable: true },
autoDraggerLength: false,
theme:"dark-thin",
mouseWheel:{ preventDefault: true },
mouseWheel:{ invert: true},
            callbacks:{
                whileScrolling:function(){ WhileScrolling(); } 
            }
        });
        function WhileScrolling(){
            $("img.lazy").lazyload();
        }
    });
})(jQuery);
</script>

任何投入将不胜感激。

4

0 回答 0