延迟加载无法与Smartphoto灯箱配合使用的图像

时间:2018-08-31 23:07:25

标签: javascript lightbox

延迟加载的图像不适用于我正在使用的Smartphoto灯箱。

这部分触发立即加载图像,而不是在达到阈值时加载图像:

_4E3F492A_FB57_4439_9BF0_1567ED84A3A9_0_1_0

是否有一种方法可以使<a href="https://via.placeholder.com/350x120" class="js-smartPhoto" data-caption="test" data-id="test" data-group="test"><img src="https://via.placeholder.com/10x10" class="svg" /> 内部的图片也可以延迟加载?

<a href="">
/*! 
 * Smartphoto
 * license: MIT (http://opensource.org/licenses/MIT)
 * author: appleple
 * homepage: http://developer.a-blogcms.jp
 * version: 1.1.0
 */

window.addEventListener('DOMContentLoaded',function(){
  new SmartPhoto(".js-smartPhoto",{
    resizeStyle: 'fit',
    arrows: true,
    nav: false
  });
});



// LazyLoad
// Copyright (c) 2015 by Andrea Verlicchi (https://github.com/verlok/lazyload)
// License (MIT): https://github.com/verlok/lazyload/blob/master/LICENSE

(function(w, d){
  var b = d.getElementsByTagName('body')[0];
  var s = d.createElement("script");
  var v = !("IntersectionObserver" in w) ? "8.15.0" : "10.16.1";
  s.async = true; // This includes the script as async. See the "recipes" section for more information about async loading of LazyLoad.
  s.src = "https://cdnjs.cloudflare.com/ajax/libs/vanilla-lazyload/" + v + "/lazyload.min.js";
  w.lazyLoadOptions = {
    elements_selector: ".lazy",
    threshold: "300"
  };
  b.appendChild(s);
}(window, document));

0 个答案:

没有答案