欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

jquery Swipebox 放大后滑动整屏滑动 全屏 图片 有大用 有大大用 有大大大用

 
  • image

  • image

  • image

  • image

 

What is Swipebox ?

Swipebox is a jQuery "lightbox" plugin for desktop, mobile and tablet.

 

Main Features

  1. Swipe gestures for mobile

  2. Keyboard Navigation for desktop

  3. CSS transitions with jQuery fallback

  4. Retina support for UI icons

  5. Easy CSS customization

 

Compatibility

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

 

Basic Usage

Javascript

Include jquery and the swipebox script in your head tags or right before yourbody closing tag.

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

CSS

Include the swipebox CSS style in your head tags.

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

HTML

Use a specific class for your links and use the title attribute as caption.

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

Fire the plugin

Bind the swipebox behaviour on every link with the "swipebox" class.

<script type="text/javascript">
;( function( $ ) {

	$( '.swipebox' ).swipebox();

} )( jQuery );
</script>
 

Advanced

 

Gallery

You can add a rel attribute to your links to seperate your galleries.

<!-- 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>
 

Video support

Simply paste a youtube or vimeo video URL in your href attribute. The script will automatically check if it's a youtube or vimeo URL and open the video in the swipebox.

My Video

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

Load slides dynamically

You can set your gallery dynamically by passing an array object to the swipebox.

View gallery

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

Check open state

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

Options

<script type="text/javascript">
;( function( $ ) {

	$( '.swipebox' ).swipebox( {
		useCSS : true, // false will force the use of jQuery for animations
		useSVG : true, // false to force the use of png for buttons
		initialIndexOnArray : 0, // which image index to init when a array is passed
		hideCloseButtonOnMobile : false, // true will hide the close button on mobile devices
		removeBarsOnMobile : true, // false will show top bar on mobile devices
		hideBarsDelay : 3000, // delay before hiding bars on desktop
		videoMaxWidth : 1140, // videos max width
		beforeOpen: function() {}, // called before opening
		afterOpen: null, // called after opening
		afterClose: function() {}, // called after closing
		loopAtEnd: false // true will return to the first image after the last image is reached
	} );

} )( jQuery );
</script>

查看源码
下载

来自  http://brutaldesign.github.io/swipebox/


来自 https://github.com/brutaldesign/swipebox

//当大图显示时 
下面的代码在手机上和电脑上都可以用 但是是在点击图像外面 并不是放大的图像里面
<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');
          });
    });



//当大图显示时  
//点击某处触发关闭按钮的事件 (也就是点击关闭大图,回到原来的状态) 我的方法是 
下面是我的方法 经测试 在电脑上是可以正常使用的 但在手机上不行


$('#swipebox-slider .current').live('click', function(){ 
      $('#swipebox-close').trigger('click'); 
});

</script>


下面做的绝对有大用
//仔细看了jquery.swipebox.min.js 的源代码,然后在网上查了一下 源来click事件在手机端的情况下 jquery.swipebox.min.js被阻止了

我使用了click的代替方法 见 /node/7380 /node/7381 引入fastclick.js文件,且 实例化fastclick  它的作用是模拟click方法,比click方法快 但不是click方法,
修改了 约jquery.swipebox.min.js(格式化为多行) 216行的代码,主要目的是 添加 
.bind('click',function(e){

    $('#swipebox-close').trigger('click');//触发关闭叉的click事件
})




Swipebox.

A touchable jQuery lightbox

  

 

What is Swipebox ?

Swipebox is a jQuery "lightbox" plugin for desktop, mobile and tablet.

 

Main Features

  1. Swipe gestures for mobile

  2. Keyboard Navigation for desktop

  3. CSS transitions with jQuery fallback

  4. Retina support for UI icons

  5. Easy CSS customization

 

Compatibility

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


 

Try it

nuke
leap
reine
neptune

 

Basic Usage

Javascript

Include jquery and the swipebox script in your head tags or right before your body closing tag.

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

CSS

Include the swipebox CSS style in your head tags.

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

HTML

Use a specific class for your links and use the title attribute as caption.

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

Fire the plugin

Bind the swipebox behaviour on every link with the "swipebox" class.

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

 

Advanced

 

Use "rel" Attribute

You can add a rel attribute to your links to seperate galleries.

<!-- 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 support

Simply paste a youtube video URL in your href attribute. The script will automatically check if it's a Youtube URL and open the video in the swipebox.

My Video

<a class="swipebox-video" rel="youtube" href="http://www.youtube.com/watch?v=XSGBVzeBUbk">My Videos</a>
 

Load slides dynamically

You can set your gallery dynamically by passing an array object to the swipebox.

View gallery

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

Refresh Method

The refresh method allows you to reload the slides if the DOM has changed.

var swipeboxInstance = $(".a:visible").swipebox();

// Use the refresh method after your event is completed
swipeboxInstance.refresh();

For exemple, if you use isotope filter.

nuke
leap
reine
neptune
// Use the swipebox only for  visible elements
var swipeboxInstance = $(".swipebox-isotope:not(.isotope-hidden .swipebox-isotope)").swipebox();

// Callback function that fire the refresh method, once the animation is finished
onAnimationCompleted = function(){
	swipeboxInstance.refresh();
};

// Isotope stuff
optionFilterLinks = $('#filter').find('a');
optionFilterLinks.attr('href', '#');

optionFilterLinks.click( function(){
	var selector = $(this).attr('data-filter');
	$('#grid').isotope({ 
		filter : '.' + selector, 
		itemSelector : '.item',
		layoutMode : 'fitRows',
		animationEngine : 'best-available',
	}, onAnimationCompleted); // callback here

	optionFilterLinks.removeClass('active');
	$(this).addClass('active');

	return false;
});
 

Check open state

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

Options

<script type="text/javascript">
jQuery(function($) {
	$(".swipebox").swipebox({
		useCSS : true, // false will force the use of jQuery for animations
		hideBarsDelay : 3000, // 0 to always show caption and action bar
		videoMaxWidth : 1140, // videos max width
		beforeOpen: function(){}, // called before opening
	      	afterClose: function(){} // called after closing
	});
});
</script>
 
来自  http://transbetty.com/tmp/swipebox/
附件大小
Package icon swipebox-master.zip66.15 KB
普通分类: