jQuery灯箱效果插件-Swipebox

下载地址:https://github.com/brutaldesign/swipebox/archive/master.zip

备用下载:点击下载

主要特点

        滑动手势移动

        键盘导航的桌面

        CSS过渡使用jQuery后备

        针对UI图标支持视网膜

        简单的CSS定制

 

基本用法

使用Javascript

在您的页面中添加jQuery和swipebox脚本

<script src="lib/jquery-2.0.3.js"></script>
<script src="source/jquery.swipebox.js"></script> 

CSS

在您的页面中添加swipebox CSS样式标签。

<link rel="stylesheet" href="source/swipebox.css"> 

HTML

使用特定的类为你的链接和使用title属性为标题。

<a href="big/image.jpg" class="swipebox" title="My Caption">
    <img src="small/image.jpg" alt="image">
</a>

绑定了“swipebox”类。

<script type="text/javascript">
    jQuery(function($) {
        $(".swipebox").swipebox();
    });
</script>

使用“rel”属性

你可以添加一个REL属性,你的链接到单独的画廊。

<!-- Gallery 1 -->
<a rel="gallery-1" href="big/image1.jpg" class="swipebox">
    <img src="small/image1.jpg" alt="image">
</a>
<a rel="gallery-1" href="big/image2.jpg" class="swipebox">
    <img src="small/image2.jpg" alt="image">
</a>
<!-- Gallery 2 -->
<a rel="gallery-2" href="big/image3.jpg" class="swipebox">
    <img src="small/image3.jpg" alt="image">
</a>
<a rel="gallery-2" href="big/image4.jpg" class="swipebox">
    <img src="small/image4.jpg" alt="image">
</a>

视频支持

只需在您的href属性粘贴视频网址。该脚本会自动检查它是否是一个视频网址,并在打开的swipebox视频。

<a class="swipebox-video" rel="视频" href="#">My Videos</a>

动态加载的幻灯片

你可以通过一个数组对象传递给swipebox动态设置您的画廊。

$("#gallery").click(function(e){
    e.preventDefault();
    $.swipebox([
        {href:'big/image1.jpg', title:'My Caption'}, 
        {href:'big/image2.jpg', title:'My Second Caption'}
    ]);
});

刷新方法

刷新方法可以让你重新加载幻灯片,如果在DOM发生了变化。

var swipeboxInstance = $(".a:visible").swipebox();
// Use the refresh method after your event is completed
swipeboxInstance.refresh();

检查打开状态

if ($.swipebox.isOpen){
    // do stuff
}

选项

<script type="text/javascript">
    jQuery(function($) {
        $(".swipebox").swipebox({
            useCSS : true, // false将强制使用的jQuery的动画 
            hideBarsDelay : 3000, // 0始终显示标题和动作条 
            videoMaxWidth : 1140, // 视频最大宽度 
            beforeOpen: function(){}, // 被叫开幕前 
            afterClose: function(){} // 被叫结束后 
        });
    });
</script>
posted @ 2016-06-15 17:30  罗锐原  阅读(1206)  评论(0编辑  收藏  举报