以下是 右侧缩略图切换jQuery焦点图轮播滚动切换特效代码 的示例演示效果:
部分效果截图:
HTML代码(index.html):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>右侧缩略图切换jQuery焦点图</title>
<link type="text/css" href="css/zzsc.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.jcarousel.min.js"></script>
<script type="text/javascript" src="js/jquery.pikachoose.min.js"></script>
<script type="text/javascript" src="js/jquery.touchwipe.min.js"></script>
</head>
<body>
<!-- 代码 开始 -->
<div class="pikachoose">
<ul id="pikame" class="jcarousel-skin-pika">
<li><a href="#" target="_blank"><img src="images/1.jpg" /></a><span>This is an example of the basic theme.</span></li>
<li><a href="#" target="_blank"><img src="images/2.jpg" /></a><span>jCarousel is supported and can be integrated with PikaChoose!</span></li>
<li><a href="#" target="_blank"><img src="images/3.jpg" /></a><span>Be sure to check out 13141618.taobao.com for updates.</span></li>
<li><a href="#" target="_blank"><img src="images/4.jpg" /></a><span>You can use any type of html you want with PikaChoose</span></li>
<li><a href="#" target="_blank"><img src="images/5.jpg" /></a><span>PikaChoose survives on your donations! Keep the project alive with a donation.</span></li>
</ul>
</div>
<script language="javascript">
$(document).ready(function () {
$("#pikame").PikaChoose({ carousel: true, carouselVertical: true });
});
</script>
</body>
</html>
JS代码(jquery.touchwipe.min.js):
/** * jQuery Plugin to obtain touch gestures from iPhone,iPod Touch and iPad,should also work with Android mobile phones (not tested yet!) * Common usage:wipe images (left and right to show the previous or next image) * * @author Andreas Waltl,netCU Internetagentur (http://www.netcu.de) * @version 1.1.1 (9th December 2010) - fix bug (older IE's had problems) * @version 1.1 (1st September 2010) - support wipe up and wipe down * @version 1.0 (15th July 2010) */
(function($){
$.fn.touchwipe=function(settings){
var config={
min_move_x:20,min_move_y:20,wipeLeft:function(){
}
,wipeRight:function(){
}
,wipeUp:function(){
}
,wipeDown:function(){
}
,preventDefaultEvents:true}
;
if(settings)$.extend(config,settings);
this.each(function(){
var startX;
var startY;
var isMoving=false;
function cancelTouch(){
this.removeEventListener('touchmove',onTouchMove);
startX=null;
isMoving=false}
function onTouchMove(e){
if(config.preventDefaultEvents){
e.preventDefault()}
if(isMoving){
var x=e.touches[0].pageX;
var y=e.touches[0].pageY;
var dx=startX-x;
var dy=startY-y;
if(Math.abs(dx)>=config.min_move_x){
cancelTouch();
if(dx>0){
config.wipeLeft()}
else{
config.wipeRight()}
}
else if(Math.abs(dy)>=config.min_move_y){
cancelTouch();
if(dy>0){
config.wipeDown()}
else{
config.wipeUp()}
}
}
}
function onTouchStart(e){
if(e.touches.length==1){
startX=e.touches[0].pageX;
startY=e.touches[0].pageY;
isMoving=true;
this.addEventListener('touchmove',onTouchMove,false)}
}
if('ontouchstart'in document.documentElement){
this.addEventListener('touchstart',onTouchStart,false)}
}
);
return this}
}
)(jQuery);
CSS代码(zzsc.css):
/* Just for the example. Fee free to delete these three lines */
body{font-family:Helvetica,sans-serif;}
.pikachoose{width:520px;margin:0 auto;}
/* Style the thumbnails */
.pika-thumbs{padding:0 16px;height:75px;}
.pika-thumbs li{width:144px;height:74px;margin:10px 0 0 17px;padding:0;overflow:hidden;float:left;list-style-type:none;padding:3px;margin:0 5px;background:#fafafa;border:1px solid #e5e5e5;cursor:pointer;}
.pika-thumbs li .clip{position:relative;height:100%;text-align:center;vertical-align:middle;overflow:hidden;}
/* The stage is the wrapper. The image fills 100% the height of the stage */
.pika-stage,.pika-textnav{width:500px;}
.pika-stage{position:relative;background:#fafafa;border:1px solid #e5e5e5;padding:10px 10px 40px 10px;text-align:center;height:250px;}
.pika-stage img{height:100%;}
.pika-stage .caption{position:absolute;background:#000;background:rgba(0,0,0,0.75);border:1px solid #141414;font-size:11px;color:#fafafa;padding:10px;text-align:right;bottom:50px;right:10px;}
.pika-stage .caption p{padding:0;margin:0;line-height:14px;}
/* Ths play,pause,prev and next buttons */
.pika-imgnav a{position:absolute;text-indent:-5000px;display:block;z-index:3;}
.pika-imgnav a.previous{background:url(prev.png) no-repeat left 45%;height:100%;width:50px;top:10px;left:10px;cursor:pointer;}
.pika-imgnav a.next{background:url(next.png) no-repeat right 45%;height:100%;width:50px;top:10px;right:10px;cursor:pointer;}
.pika-imgnav a.play{background:url(play.png) no-repeat 0% 50%;height:100px;width:44px;top:0;left:50%;display:none;cursor:pointer;}
.pika-imgnav a.pause{background:url(pause.png) no-repeat 0% 50%;height:100px;width:44px;top:0;left:50%;display:none;cursor:pointer;}
/* The previous and next textual buttons */
.pika-textnav{overflow:hidden;margin:10px 0 0 0;bottom:10px;position:absolute;}
.pika-textnav a{font-size:12px;text-decoration:none;color:#333;padding:4px;}
.pika-textnav a.previous{float:left;width:auto;display:block;}
.pika-textnav a.next{float:right;width:auto;display:block;}
/*for the tool tips*/
.pika-tooltip{font-size:12px;position:absolute;color:white;padding:3px;background-color:rgba(0,0,0,0.7);border:3px solid black;}
.pika-counter{position:absolute;bottom:45px;left:15px;color:white;background:rgba(0,0,0,0.7);font-size:11px;padding:3px;-moz-border-radius:5px;border-radius:5px;}
/* If using user thumbnails there's a pause well the new large image loads. This is the loader for that */
.pika-loader{background:url(loading.gif) 3px 3px no-repeat #000;background-color:rgba(0,0,0,0.9);color:white;width:60px;font-size:11px;padding:5px 3px;text-align:right;position:absolute;top:15px;right:15px;}
/*if you just want to adjust the size of the stage and the thumbnails,you can do so by editing the following lines:*/
.pika-thumbs li{width:90px;height:55px;}
.pikachoose{width:680px;position:relative;}
#pikame{width:150px;}
.pika-thumbs{margin:10px 0 0 17px;width:250px;position:absolute;top:10px;right:30px;}
.pika-thumbs li{margin:5px 5px;}
/* jCarousel Styles */
/*if you're not using the carousel you can delete everything below this */
.jcarousel-skin-pika{position:absolute;top:35px;right:20px;}
.jcarousel-skin-pika .jcarousel-container-vertical{width:125px;height:230px;overflow:hidden;}
.jcarousel-skin-pika .jcarousel-clip-vertical{width:125px;height:230px;}
.jcarousel-skin-pika .jcarousel-item-vertical{margin-top:10px;}