Lightbox/弹窗

jQuery支持移动触屏Lightbox插件

阿里云

Swipebox 是一款支持桌面、移动触摸手机和平板电脑的 jquery Lightbox 插件。该 lightbox 插件支持手机的触摸手势,支持桌面电脑的键盘导航,并且支持视频的播放。Swipebox 的特点有:

支持手机的触摸手势

也想出现在这里?联系我们
创客主机

支持桌面电脑的键盘导航

通过 jQuery 回调提提供 CSS 过渡效果

Retina 支持 UI 图标

CSS 样式容易定制

使用方法:

首先在[body]标签之前或[header]标签中引入 jquery 和 swipebox js 文件。

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

标签中引入 swipebox.css 文件。

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

HTML 结构:

为超链接标签使用指定的 class,使用 title 属性来指定图片的标题:

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

调用插件:

通过.swipebox 选择器来绑定该 lightbox 的 swipebox 事件:

  1. <script type="text/javascript">
  2.     ;( function( $ ) {
  3.  
  4.         $( '.swipebox' ).swipebox();
  5.  
  6.     } )( jQuery );
  7. </script>

高级配置:

你可以在超链接标签中添加一个 rel 属性来分割画廊图片

  1. <!-- Gallery 1 -->
  2. <a rel="gallery-1" href="big/image1.jpg" class="swipebox">
  3.     <img src="small/image1.jpg" alt="image">
  4. </a>
  5. <a rel="gallery-1" href="big/image2.jpg" class="swipebox">
  6.     <img src="small/image2.jpg" alt="image">
  7. </a>
  8. <!-- Gallery 2 -->
  9. <a rel="gallery-2" href="big/image3.jpg" class="swipebox">
  10.     <img src="small/image3.jpg" alt="image">
  11. </a>
  12. <a rel="gallery-2" href="big/image4.jpg" class="swipebox">
  13.     <img src="small/image4.jpg" alt="image">
  14. </a>

视频支持:

你可以将一个 youtube 或 vimeo 的视频 URL 放到 href 属性中,该 lightbox 插件会自动检测它是否是 youtube 或 vimeo 的视频,并用 swipebox 打开它。

  1. <a class="swipebox-video" rel="vimeo" href="http://vimeo.com/29193046">My Videos</a>

你可以通过一个数组来动态调用你的画廊:

  1. $( '#gallery' ).click( function( e ) {
  2.     e.preventDefault();
  3.     $.swipebox( [
  4.         { href:'big/image1.jpg', title:'My Caption' }, 
  5.         { href:'big/image2.jpg', title:'My Second Caption' }
  6.     ] );
  7. } );

检测状态:

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

可用参数:

  1. <script type="text/javascript">
  2.     ;( function( $ ) {
  3.         $( '.swipebox' ).swipebox( {
  4.             useCSS : true, // false will force the use of jQuery for animations
  5.             useSVG : true, // false to force the use of png for buttons
  6.             initialIndexOnArray : 0, // which image index to init when a array is passed
  7.             hideCloseButtonOnMobile : false, // true will hide the close button on mobile devices
  8.             hideBarsDelay : 3000, // delay before hiding bars on desktop
  9.             videoMaxWidth : 1140, // videos max width
  10.             beforeOpen: function() {}, // called before opening
  11.             afterOpen: null, // called after opening
  12.             afterClose: function() {} // called after closing
  13.             loopAtEnd: false // true will return to the first image after the last image is reached
  14.         } );
  15.     } )( jQuery );
  16. </script>

useCSS:设置为 false 将强制 lightbox 使用 jQuery 来动画。

useSVG:设置为 flase 将 lightbox 使用 png 来制作按钮。

initialIndexOnArray:当 lightbox 使用数组时使用该参数来设置下标。

hideCloseButtonOnMobile:设置为 true 时 lightbox 将在移动设备上隐藏关闭按钮。

hideBarsDelay:lightbox 在桌面设备上隐藏信息条的延时时间。

videoMaxWidth:lightbox 视频的最大宽度。

beforeOpen:lightbox 打开前的回调函数。

afterOpen:lightbox 打开后的回调函数。

afterClose:lightbox 关闭后的回调函数。

loopAtEnd:设置为 true 时 lightbox 将在播放到最后一张图片时接着返回第一张图片播放。

jQuery 支持移动触屏 Lightbox 插件

已有 328 人购买
查看演示升级 VIP立刻购买

演示地址 下载地址
收藏
(0)

发表回复

热销模板

Ashade - 作品展示摄影相册WordPress汉化主题
LensNews

本站承接 WordPress / PbootCMS / DedeCMS 等
系统建站、仿站、开发、定制等业务!