gpt4 book ai didi

jquery - Magnific-Popup Gallery 不要打开两次

转载 作者:行者123 更新时间:2023-12-05 07:27:09 31 4
gpt4 key购买 nike

我想从缩略图列表中打开一个宏伟的弹出式画廊。

画廊打开一次,一切正常,但如果我关闭画廊,我就不能打开两次,我有这个错误:

未捕获的类型错误:无法读取未定义的属性“top”

magnific-popup.js 中这一行的错误报告:offset.top -= ( $(window).scrollTop() - paddingTop );

<div id="filelist">
<div id="156" class="entreprise_img" style="background: url('5c30ff09d7566.jpg') no-repeat center;-moz-background-size: cover;-webkit-background-size: cover;background-size: cover;">
<a href="#" class="entreprise_photo_btn_delete" title="Supprimer">Supprimer</a>
<a href="5c30ff09d7566.jpg" class="magnific-gallery" style="position: absolute; bottom: 0;">VOIR</a>
</div>
<div id="157" class="entreprise_img" style="background: url('5c3104cab1fb7.jpg') no-repeat center;-moz-background-size: cover;-webkit-background-size: cover;background-size: cover;">
<a href="#" class="entreprise_photo_btn_delete" title="Supprimer">Supprimer</a>
<a href="5c3104cab1fb7.jpg" class="magnific-gallery" style="position: absolute; bottom: 0;">VOIR</a>
</div>
</div>


$('#filelist').each(function(){
$(this).magnificPopup({
delegate: '.magnific-gallery',
type: 'image',
closeOnContentClick: false,
closeBtnInside: false,
mainClass: 'mfp-with-zoom mfp-img-mobile',
image: {
verticalFit: true
},
gallery: {
enabled: true
},
zoom: {
enabled: true,
duration: 300, // don't foget to change the duration also in CSS
opener: function(element) {
return element.find('img');
}
}
});
});

最佳答案

我也有类似的错误。解决方法很简单:你需要重写 zoom 属性中的 opener 方法,让它检查打开的对象是否是图像。

zoom: {
enabled: true,
duration: 300,
opener: function (element) {
return element.is('img') ? element : element.find('img');
}
}

关于jquery - Magnific-Popup Gallery 不要打开两次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54055797/

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