jquery图片幻灯片殊效教程源码分享_Javascript教程
2013-12-03 14:38
633 查看
//图片幻灯展现 $(function() { var imgPro = { imgWidth : 626, //图片宽度 imgConLength : 0, //图片总长度 index : 0, //导航锁定索引 count : 0, //图片数目 left : 0, //相对定位left pre : -1, //上个图片索引 curr : 0, //当前图片索引 next : 1, //下个图片索引 direction : 1, //主动播放方向 interTime : 3000//距离时光 } addImgAlt(imgPro.curr);
imgPro.count = $('#banner .list a img').length; imgPro.imgConLength = imgPro.imgWidth * imgPro.count; imgPro.left = parseInt($('#box .list ul').css("left")); //播放按时器 var t = setInterval(imgPlay, imgPro.interTime); $('#box .arrowl img, #box .arrowr img,#banner
.list a,#box .count li,#box p').hover(function() { clearInterval(t); }, function() { t = setInterval(imgPlay, imgPro.interTime); }); // 自动播放图片 function imgPlay() { if ((imgPro.next != imgPro.count && imgPro.direction == 1) (imgPro.pre == -1 && imgPro.direction
== -1)) { imgPro.direction = 1; toNext(); } else { imgPro.direction = -1; toLast(); } } //点击左标的目的 $('#box .arrowl img').click(function() { if (imgPro.curr != 0) { toLast(); } }); //点击右方向 $('#box .arrowr img').click(function() { if (imgPro.next != imgPro.count)
{ toNext(); } }); //点击导航播放 $('#box .count li').click(function() { imgPro.index = $('#box .count li').index(this); if (imgPro.curr != imgPro.index) { imgPro.left += (imgPro.curr - imgPro.index) * imgPro.imgWidth; addImgAlt(imgPro.index); play(); $('#box .count
li').eq(imgPro.curr).removeClass('current').end().eq(imgPro.index).addClass('current'); imgPro.curr = imgPro.index; imgPro.pre = imgPro.index - 1; imgPro.next = imgPro.index + 1; } }); //播放 function play() { $('#box .list ul').css({ 'opacity' : '0.5' }).animate({
'left' : imgPro.left + "px", 'opacity' : '1' }, 'slow'); } //增加图片阐明信息 function addImgAlt(index) { $("#box p").text($("#banner .list a img").eq(index).attr("alt")); } //上一张 function toLast() { imgPro.left += imgPro.imgWidth; addImgAlt(imgPro.pre); play(); $('#box
.count li').eq(imgPro.curr).removeClass('current').end().eq(imgPro.pre).addClass('current'); imgPro.pre--; imgPro.curr--; imgPro.next--; } //下一张 function toNext() { imgPro.left -= imgPro.imgWidth; addImgAlt(imgPro.next); play(); $('#box .count li').eq(imgPro.curr).removeClass('current').end().eq(imgPro.next).addClass('current');
imgPro.pre++; imgPro.curr++; imgPro.next++; } });
imgPro.count = $('#banner .list a img').length; imgPro.imgConLength = imgPro.imgWidth * imgPro.count; imgPro.left = parseInt($('#box .list ul').css("left")); //播放按时器 var t = setInterval(imgPlay, imgPro.interTime); $('#box .arrowl img, #box .arrowr img,#banner
.list a,#box .count li,#box p').hover(function() { clearInterval(t); }, function() { t = setInterval(imgPlay, imgPro.interTime); }); // 自动播放图片 function imgPlay() { if ((imgPro.next != imgPro.count && imgPro.direction == 1) (imgPro.pre == -1 && imgPro.direction
== -1)) { imgPro.direction = 1; toNext(); } else { imgPro.direction = -1; toLast(); } } //点击左标的目的 $('#box .arrowl img').click(function() { if (imgPro.curr != 0) { toLast(); } }); //点击右方向 $('#box .arrowr img').click(function() { if (imgPro.next != imgPro.count)
{ toNext(); } }); //点击导航播放 $('#box .count li').click(function() { imgPro.index = $('#box .count li').index(this); if (imgPro.curr != imgPro.index) { imgPro.left += (imgPro.curr - imgPro.index) * imgPro.imgWidth; addImgAlt(imgPro.index); play(); $('#box .count
li').eq(imgPro.curr).removeClass('current').end().eq(imgPro.index).addClass('current'); imgPro.curr = imgPro.index; imgPro.pre = imgPro.index - 1; imgPro.next = imgPro.index + 1; } }); //播放 function play() { $('#box .list ul').css({ 'opacity' : '0.5' }).animate({
'left' : imgPro.left + "px", 'opacity' : '1' }, 'slow'); } //增加图片阐明信息 function addImgAlt(index) { $("#box p").text($("#banner .list a img").eq(index).attr("alt")); } //上一张 function toLast() { imgPro.left += imgPro.imgWidth; addImgAlt(imgPro.pre); play(); $('#box
.count li').eq(imgPro.curr).removeClass('current').end().eq(imgPro.pre).addClass('current'); imgPro.pre--; imgPro.curr--; imgPro.next--; } //下一张 function toNext() { imgPro.left -= imgPro.imgWidth; addImgAlt(imgPro.next); play(); $('#box .count li').eq(imgPro.curr).removeClass('current').end().eq(imgPro.next).addClass('current');
imgPro.pre++; imgPro.curr++; imgPro.next++; } });
相关文章推荐
- 【示例代码】3D旋转图片立体展示jquery幻灯片插件(附源码)
- 分享16个javascript&jQuery的MVC教程
- 分享16个javascript&jQuery的MVC教程
- jquery的幻灯片图片切换效果代码分享
- Javascript实现图片位置控制(鼠标拖拽 + 键盘方向键移动)源码分享
- 33个优秀的jQuery 教程分享(幻灯片、动画菜单)
- 20个非常棒的 jQuery 幻灯片插件和教程分享
- 分享16个javascript&jQuery的MVC教程
- 3D旋转图片立体展示jquery幻灯片插件(附源码)
- 分享16个javascript&jQuery的MVC教程
- 33个优秀的jQuery 教程分享(幻灯片、动画菜单)
- php+flash+jQuery多图片上传源码分享
- php+flash+jQuery多图片上传源码分享
- 分享10个jQuery图片加载插件和教程及其生成器
- 10个用jQuery实现图片幻灯片/画廊效果和源码
- Javascript实现图片位置控制(鼠标拖拽 + 键盘方向键移动)源码分享
- 分享简单实用的jQuery图片播放实例和源码
- jquery的幻灯片图片切换效果代码分享
- 分享10篇优秀的jQuery幻灯片制作教程及应用案例