jquery全屏图片幻灯片展示特效

本文介绍了一个使用jQuery实现的图片自动扩展插件,它能够覆盖整个屏幕或特定区域,每张图片支持平移、放大、缩小等效果,并允许自定义标题与内容展示方式。详细说明了如何将CSS与JS文件引入,创建所需的HTML结构,并通过jQuery代码配置插件的各项功能,包括设置循环播放次数、执行自定义代码等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

这是一个超大的幻灯片自动扩展以填补容器来显示你的图片,可以覆盖整个屏幕,或某一区域。每张图片都可以设置平移,放大或放小等效果,还可以自定义标题和让其中内容永久展示。还可以设置幻灯片连续运行几次后停止,每一个图像的变化后,执行自定义代码等。是一个支持各种平台的响应式布局的jquery图片插件。

使用说明:

1.加入css与js文件

<link rel="stylesheet" type="text/css" href="smooth_slider.css">

	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
	<script src="jquery-slider.js">

2.在body内加入内容

<div id="throbber"><img src="img/throbber.gif"></div>
<div id="resume" style="display:none">Replay</div>
<div id="pan_area" style="height:100%"></div>
<div id="img_msg_area"><span></span></div>
<div id="static_text_area">There is nothing more amazing than nature, the miracle that is every creature in her domain. The birds, the lions, down to every insect, together they form the circle of life that supports each other.</div>
throbber为载入图片时的loading

resume重新播放按钮

pan_area显示幻灯片的位置

img_msg_area显示图片说明,也是js中playlist中的caption显示的位置。

3.jquery代码使用

<script>
		$(function() {
			$('#resume').on('click', function(){ // set up resume button behavior
				$("#pan_area").smoothslider("resume") // resume playing of this slideshow. Pass in "pause" to pause it instead
				$(this).hide() // hide resume button
			})
		
		
			$("#pan_area").smoothslider("install", {
				// either "playlist" or "playlist_url" must be specified.

				// "playlist" is a list of dictionaries. Each dictionary specifies the necessary information
				// to display one image and it can have the following fields:
				//    "url" - url of the image
				//    "caption" - a text to pass to the on_image_change when the given image is going
				//                to be displayed
				//    "slide" - specifies how the sliding should occur. It's a dictionary with the
				//                following values:
				//         "x1" - initial x position. The range is 0 ... image width
				//         "x2" - final x position. The range is 0 ... image width
				//         "y1" - initial y position. The range is 0 ... image height
				//         "y2" - final y position. The range is 0 ... image height
				//         "z1" - initial zoom. It should be >= 1
				//         "z2" - final zoom. It should be >= 1
				//         "hint" -  can be one of:
				//              "zoom" - zoom
				//              "hpan" - pan horizontally
				//              "vpan" - pan vertically
				//
				//         When the browser has limited support, the plugin will only perform 
				//         one motion (horizontal/vertical panning or zooming).
				//         If "hint" is used, then the specified motion is used instead.
				//         If "slide" is not specified, then a random motion is used
				//         If "slide" has an empty dictionary, then no motion is performed

				// "playlist_url" is a url of a json file which specifies among other things
				// a playlist. Besides that, it can also contain some parameters,
				// which if specified, will override the ones specified when calling smoothslider.
				// Besides the playlist, the parameters that can be specified in the json file are:
				// 
				// "preload_images", "anim_fps", "transition_time", "hold_time", "loops"
			
				"playlist":[
							{"url":"img/img0.jpg", 
							 "caption":"渐渐放大",
							 "slide":{"z1":1, "z2":1.5}}, // zoom in (magnification from 1 to 1.5)

							{"url":"img/img1.jpg",
							"caption":"渐渐缩小",
							 "slide":{"z1":2, "z2":1}}, // zoom out

							{"url":"img/img2.jpg",
							"caption":"渐渐向上",
							 "slide":{"y1":0, "y2":200}}, // pan up

							{"url":"img/img3.jpg",
							 "caption": "渐渐向左变化",
							 "slide":{"x1":0, "x2":20, "z1":1}}, // pan left

							{"url":"img/img4.jpg", "caption":"没有动画的展示","slide":{}} // no slide
							],


				"loops":2, // play everything twice and then pause. If not specified, the slider will
				           // play indefinitely
	
		   "hold_time":2,
			 "transition_time":1,

				// this function gets called whenever there's an image change
				"on_image_change":function(caption, image_url) { 
						var area= $("#img_msg_area").find("span");
						area.animate({"opacity": 0}, 500, "swing", function() {
							area.text(caption);
							area.animate({"opacity": 1}, 500); // fade in & out take 500ms each
						});
					},
				"throbber":$("#throbber"), // an image to show when waiting for images to load
				on_pause:function(){
					$('#resume').show()
				}

			});
		});

	</script>
主要内容都在playlist数组中,url:图片路径;caption:图片标题;slide:设置各图片的不同放大、缩小、移动等效果。


"loops":2 为循环2次后停止播放。

"hold_time":2 延时时间2秒。

"transition_time":1过度时间为1秒。


文章 转载自:http://www.jsctrlc.com/texiao/156.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值