【发布时间】:2017-08-28 20:22:48
【问题描述】:
我正在使用 freewall 和 featherlight 插件的混合物来生成一个打开到灯箱的响应式画廊,但是,我在尝试让灯箱切换到下一个图像 (i + 1) 时遇到以下问题点击。 灯箱图片代码enter image description here。我想要做的是将 img src 更改为 i + 1 以便在点击时转到下一个图像。
我在 Github 上也有这个项目,可能有助于理解:https://github.com/adamianniello/adamianniello.com/blob/master/B%C3%A6b%C3%A6l%C9%99n_Pasadena.html
<script type="text/javascript">
var temp = "<div class='brick' style='width:{width}px;'><a href='#' data-featherlight='i/jpl/{link}.jpg'><img src='i/jpl/{index}.jpg' width='100%'></a></div>";
var w = 1, h = 1, html = '', limitItem = 54;
for (var i = 0; i < limitItem; ++i) {
w = 1 + 3 * Math.random() << 0;
html += temp.replace(/\{width\}/g, w*150).replace("{index}", i + 1).replace("{link}",i + 1);
}
$("#freewall").html(html);
var wall = new Freewall("#freewall");
wall.reset({
selector: '.brick',
animate: true,
cellW: 150,
cellH: 'auto',
onResize: function() {
wall.fitWidth();
}
});
var images = wall.container.find('.brick');
images.find('img').load(function() {
wall.fitWidth();
});
<div id="freewall" class="free-wall"></div>
【问题讨论】:
-
您在使用
featherlight-gallery插件吗?看来这就是你所需要的。 -
我尝试使用featherlight-gallery,但我使用的是Freewall插件来显示网格,有没有办法在不破坏Freewall插件的情况下使用featherlight-gallery?
-
我不明白为什么不这样做。
标签: javascript jquery html featherlight.js