日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

基于 jQuery支持移动触摸设备的Lightbox插件

發布時間:2023/12/10 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 基于 jQuery支持移动触摸设备的Lightbox插件 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Swipebox是一款支持桌面、移動觸摸手機和平板電腦的jquery Lightbox插件。該lightbox插件支持手機的觸摸手勢,支持桌面電腦的鍵盤導航,并且支持視頻的播放。

在線預覽???源碼下載

簡要教程

Swipebox是一款支持桌面、移動觸摸手機和平板電腦的jQuery?Lightbox插件。Swipebox的特點有:

  • 支持手機的觸摸手勢
  • 支持桌面電腦的鍵盤導航
  • 通過jQuery回調提提供CSS過渡效果
  • Retina支持UI圖標
  • CSS樣式容易定制

使用方法

首先在<body>標簽之前或<header>標簽中引入jquery和swipebox js文件。

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

在<header>標簽中引入swipebox.css文件。

<link rel="stylesheet" href="src/css/swipebox.css">
HTML結構

為超鏈接標簽使用指定的class,使用title屬性來指定圖片的標題:

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

通過.swipebox選擇器來綁定該lightbox的swipebox事件:

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

高級配置

畫廊

你可以在超鏈接標簽中添加一個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>
視頻支持

你可以將一個youtube或vimeo的視頻URL放到href屬性中,該lightbox插件會自動檢測它是否是youtube 或 vimeo的視頻,并用swipebox打開它。

<a class="swipebox-video" rel="vimeo" href="http://vimeo.com/29193046">My Videos</a>
動態調用畫廊

你可以通過一個數組來動態調用你的畫廊:

$( '#gallery' ).click( function( e ) {e.preventDefault();$.swipebox( [{ href:'big/image1.jpg', title:'My Caption' }, { href:'big/image2.jpg', title:'My Second Caption' }] ); } );
檢測狀態
if ( $.swipebox.isOpen ) {// do stuff }
可用參數
<script type="text/javascript">;( function( $ ) {$( '.swipebox' ).swipebox( {useCSS : true, // false will force the use of jQuery for animationsuseSVG : true, // false to force the use of png for buttonsinitialIndexOnArray : 0, // which image index to init when a array is passedhideCloseButtonOnMobile : false, // true will hide the close button on mobile deviceshideBarsDelay : 3000, // delay before hiding bars on desktopvideoMaxWidth : 1140, // videos max widthbeforeOpen: function() {}, // called before openingafterOpen: null, // called after openingafterClose: function() {} // called after closingloopAtEnd: false // true will return to the first image after the last image is reached} );} )( jQuery ); </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將在播放到最后一張圖片時接著返回第一張圖片播放。

瀏覽器兼容

Chrome, Safari, Firefox, Opera, IE9+, IOS4+, Android, windows phone.

via:http://***/Article/21873

轉載于:https://www.cnblogs.com/liaohuolin/p/4287829.html

總結

以上是生活随笔為你收集整理的基于 jQuery支持移动触摸设备的Lightbox插件的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。