gpt4 book ai didi

javascript - 使用 Jquery Isotope 过滤 Fancybox 图库

转载 作者:行者123 更新时间:2023-11-28 18:06:00 24 4
gpt4 key购买 nike

我正在尝试使用 Isotope 将我的图库筛选为类别,然后打开 FancyBox,并且仅在 Fancybox 中显示筛选后的类别。

这是我的代码:

HTML

<div class="filters">
<div class="ui-group">
<div class="button-group js-radio-button-group" data-filter-group="color">
<button class="button" data-filter="*">ALL</button>|
<button class="button" data-filter=".wedding">WEDDINGS</button>|
<button class="button" data-filter=".concert">CONCERT/SHOWS</button>|
<button class="button" data-filter=".corporate">CORPORATE EVENTS</button>|
<button class="button" data-filter=".church">CHURCH EVENTS</button>|
<button class="button" data-filter=".political">POLITICAL EVENTS</button>|
<button class="button" data-filter=".parties">PARTIES</button>
</div>
</div>
</div>
</div>
<!-- /.container -->
<div class="grid">
<div class="gutter-sizer"></div>
<a class='fancybox' href='../images/picture-1' data-fancybox="gallery" data-fancybox-group='gallery' data-filter='church'>
<div class="grid-item church"><img src="../images/picture-1"></div>
</a>

<a class='fancybox' href='../images/picture-2' data-fancybox="gallery" data-fancybox-group='gallery' data-filter='wedding'>
<div class="grid-item wedding"><img src="../images/picture-2"></div>
</a>

<a class='fancybox' href='../images/picture-' data-fancybox="gallery" data-fancybox-group='gallery' data-filter='church'>
<div class="grid-item church"><img src="../images/picture-3"></div>
</a>
</div>

JS

    $(".fancybox").fancybox({

});
$('#filters a').click(function(){
var selector = $(this).attr('data-filter');
$('#gallery').isotope({ filter: selector }, function(){
if(selector == "*"){
$(".fancybox").attr("data-fancybox-group", "gallery");
} else{
$(selector).find(".fancybox").attr("data-fancybox-group", selector);
}
});
return false;
});
}); // ready

最佳答案

您可以简单地创建自定义点击事件来显示可见项目:

$('.fancybox').on('click', function() {
var visibleLinks = $('.fancybox:visible');

$.fancybox.open( visibleLinks, {}, visibleLinks.index( this ) );

return false;
});

查看完整演示 - http://codepen.io/fancyapps/pen/EZKYPN

(此演示使用 v3,但 v2 也类似)

关于javascript - 使用 Jquery Isotope 过滤 Fancybox 图库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42589595/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com