问题描述
我问了作者这个问题,但是他说要我通过Github添加我想要的贡献,我不知道该怎么做,因为我不太了解JavaScript.希望大家能提供帮助. :)
I asked the author this but he said for me to add the contributions I want via Github, and I don't know how to do that as I'm not that knowledgeable with JavaScript. Hope you all can help. :)
这是插件的链接: http://brutaldesign.github.io/swipebox/
基本上,如何通过单击图片外部的任何位置来关闭灯箱?像大多数灯箱如何运作?
Basically, how could I make the lightbox close by clicking anywhere outside the image? Like how most lightboxes function?
此灯箱非常符合我的需求: http://fancyapps.com/fancybox/我不使用该灯箱,因为它没有我需要的滑动功能.
This lightbox does it perfectly how I want it: http://fancyapps.com/fancybox/I dont use that lightbox because it doesn't have the swipe functionality that I need.
我确实知道这与以下功能有关
I do know it has to be something to do with the following function
.click
提前谢谢!
推荐答案
(已更新,具有更多事件和更好的事件委托)
尝试将以下脚本添加到页面中
Try adding the following script to your page
<script>
$(function(){
$(document.body)
.on('click touchend','#swipebox-slider .current img', function(e){
return false;
})
.on('click touchend','#swipebox-slider .current', function(e){
$('#swipebox-close').trigger('click');
});
});
</script>
这篇关于灯箱点击外部图片以关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!