光滑滑块中的 Lightgallery 检测克隆幻灯片
Lightgallery in slick slider detecting clones slides
我正在使用 slick slider combined with sachinchoolur lightGallery。
我是 运行 多个滑块,我希望每个 lightgallery 与其相关滑块相关。
目前有效,但我遇到的问题是 lightgallery 正在获得光滑的滑块克隆。
通常我可以通过在 slick 中使用 infinite: false;
来解决这个问题,但在这种情况下我真的需要我的滑块是 infinite: true;
.
我无法解决这个问题,是否有解决此问题的方法?
所以只有可见的幻灯片,而不是克隆,渲染到 lightgallery。
这里有一个fiddle方便调试。 https://jsfiddle.net/joshmoto/jmvg5c93/
// init slick slider
$('.slick').slick({
dots: true,
infinite: true,
speed: 300,
slidesToShow: 1,
adaptiveHeight: true
});
// slick light gallery
$('.slick').lightGallery({
selector: '.lightgallery',
//selectWithin: '.slick-slide:not(.slick-cloned)'
});
FIGURE {
margin: 0;
width: 300px !important;
display: block !important;
}
IMG {
width: 100%;
}
.slick {
width: 300px;
margin: 0 auto 60px !important;
}
PRE {
text-align: center;
margin: 15px 0;
}
<pre>4 Space Photos - lightgallery shows 9</pre>
<div class="slick">
<figure>
<a href="https://i.imgur.com/q5Y5RCH.png" class="lightgallery">
<img src="https://i.imgur.com/q5Y5RCH.png" alt="" />
</a>
</figure>
<figure>
<a href="https://i.imgur.com/8HjXPXD.png" class="lightgallery">
<img src="https://i.imgur.com/8HjXPXD.png" alt="" />
</a>
</figure>
<figure>
<a href="https://i.imgur.com/vUDcfcy.png" class="lightgallery">
<img src="https://i.imgur.com/vUDcfcy.png" alt="" />
</a>
</figure>
<figure>
<a href="https://i.imgur.com/okTDHas.png" class="lightgallery">
<img src="https://i.imgur.com/okTDHas.png" alt="" />
</a>
</figure>
</div>
<pre>3 Sea Photos - lightgallery shows 7</pre>
<div class="slick">
<figure>
<a href="https://i.imgur.com/x7ZYW4i.png" class="lightgallery">
<img src="https://i.imgur.com/x7ZYW4i.png" alt="" />
</a>
</figure>
<figure>
<a href="https://i.imgur.com/EYTCssm.png" class="lightgallery">
<img src="https://i.imgur.com/EYTCssm.png" alt="" />
</a>
</figure>
<figure>
<a href="https://i.imgur.com/3sAFPmL.png" class="lightgallery">
<img src="https://i.imgur.com/3sAFPmL.png" alt="" />
</a>
</figure>
</div>
<pre>5 Land Photos - lightgallery shows 11</pre>
<div class="slick">
<figure>
<a href="https://i.imgur.com/IqLrd0o.png" class="lightgallery">
<img src="https://i.imgur.com/IqLrd0o.png" alt="" />
</a>
</figure>
<figure>
<a href="https://i.imgur.com/6JplNl6.png" class="lightgallery">
<img src="https://i.imgur.com/6JplNl6.png" alt="" />
</a>
</figure>
<figure>
<a href="https://i.imgur.com/6X5GKWJ.png" class="lightgallery">
<img src="https://i.imgur.com/6X5GKWJ.png" alt="" />
</a>
</figure>
<figure>
<a href="https://i.imgur.com/SefTwI1.png" class="lightgallery">
<img src="https://i.imgur.com/SefTwI1.png" alt="" />
</a>
</figure>
<figure>
<a href="https://i.imgur.com/qBmDrTU.png" class="lightgallery">
<img src="https://i.imgur.com/qBmDrTU.png" alt="" />
</a>
</figure>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/lightgallery/1.7.0/css/lightgallery.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lightgallery/1.7.0/js/lightgallery-all.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick-theme.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.js"></script>
我刚刚弄明白了...
// slick light gallery
$('.slick').lightGallery({
selector: '.slick-slide:not(.slick-cloned) .lightgallery',
});
我正在使用 slick slider combined with sachinchoolur lightGallery。
我是 运行 多个滑块,我希望每个 lightgallery 与其相关滑块相关。
目前有效,但我遇到的问题是 lightgallery 正在获得光滑的滑块克隆。
通常我可以通过在 slick 中使用 infinite: false;
来解决这个问题,但在这种情况下我真的需要我的滑块是 infinite: true;
.
我无法解决这个问题,是否有解决此问题的方法?
所以只有可见的幻灯片,而不是克隆,渲染到 lightgallery。
这里有一个fiddle方便调试。 https://jsfiddle.net/joshmoto/jmvg5c93/
// init slick slider
$('.slick').slick({
dots: true,
infinite: true,
speed: 300,
slidesToShow: 1,
adaptiveHeight: true
});
// slick light gallery
$('.slick').lightGallery({
selector: '.lightgallery',
//selectWithin: '.slick-slide:not(.slick-cloned)'
});
FIGURE {
margin: 0;
width: 300px !important;
display: block !important;
}
IMG {
width: 100%;
}
.slick {
width: 300px;
margin: 0 auto 60px !important;
}
PRE {
text-align: center;
margin: 15px 0;
}
<pre>4 Space Photos - lightgallery shows 9</pre>
<div class="slick">
<figure>
<a href="https://i.imgur.com/q5Y5RCH.png" class="lightgallery">
<img src="https://i.imgur.com/q5Y5RCH.png" alt="" />
</a>
</figure>
<figure>
<a href="https://i.imgur.com/8HjXPXD.png" class="lightgallery">
<img src="https://i.imgur.com/8HjXPXD.png" alt="" />
</a>
</figure>
<figure>
<a href="https://i.imgur.com/vUDcfcy.png" class="lightgallery">
<img src="https://i.imgur.com/vUDcfcy.png" alt="" />
</a>
</figure>
<figure>
<a href="https://i.imgur.com/okTDHas.png" class="lightgallery">
<img src="https://i.imgur.com/okTDHas.png" alt="" />
</a>
</figure>
</div>
<pre>3 Sea Photos - lightgallery shows 7</pre>
<div class="slick">
<figure>
<a href="https://i.imgur.com/x7ZYW4i.png" class="lightgallery">
<img src="https://i.imgur.com/x7ZYW4i.png" alt="" />
</a>
</figure>
<figure>
<a href="https://i.imgur.com/EYTCssm.png" class="lightgallery">
<img src="https://i.imgur.com/EYTCssm.png" alt="" />
</a>
</figure>
<figure>
<a href="https://i.imgur.com/3sAFPmL.png" class="lightgallery">
<img src="https://i.imgur.com/3sAFPmL.png" alt="" />
</a>
</figure>
</div>
<pre>5 Land Photos - lightgallery shows 11</pre>
<div class="slick">
<figure>
<a href="https://i.imgur.com/IqLrd0o.png" class="lightgallery">
<img src="https://i.imgur.com/IqLrd0o.png" alt="" />
</a>
</figure>
<figure>
<a href="https://i.imgur.com/6JplNl6.png" class="lightgallery">
<img src="https://i.imgur.com/6JplNl6.png" alt="" />
</a>
</figure>
<figure>
<a href="https://i.imgur.com/6X5GKWJ.png" class="lightgallery">
<img src="https://i.imgur.com/6X5GKWJ.png" alt="" />
</a>
</figure>
<figure>
<a href="https://i.imgur.com/SefTwI1.png" class="lightgallery">
<img src="https://i.imgur.com/SefTwI1.png" alt="" />
</a>
</figure>
<figure>
<a href="https://i.imgur.com/qBmDrTU.png" class="lightgallery">
<img src="https://i.imgur.com/qBmDrTU.png" alt="" />
</a>
</figure>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/lightgallery/1.7.0/css/lightgallery.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lightgallery/1.7.0/js/lightgallery-all.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick-theme.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.js"></script>
我刚刚弄明白了...
// slick light gallery
$('.slick').lightGallery({
selector: '.slick-slide:not(.slick-cloned) .lightgallery',
});