微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

jQuery插件animateSlide制作多点滑动幻灯片

首页banner的酷炫效果多来自全屏大图的幻灯片动画,下面提供一种完美兼容的jquery动画特效:全新jquery多点滑动幻灯片——全屏动画animateSlide(代码完全原创)。

直接上代码,把html、css和jquery代码copy到页面上即可呈现完美画面。

HTML代码如下:

rush:xhtml;">
Box present">

标题

Box">

Box">

一个奇迹啊

css代码如下:

rush:css;"> .animateSlide {width: 100%; height: 390px; position: relative; background: #f5f5f5;} .animateSlideImgWrap {width: 100%; height: 390px; position: absolute; z-index: 1; overflow: hidden;} .animateSlideImgWrap .present {display: block;} .animateSlideImgBox {width: 100%; height: 390px; position: absolute; z-index: 1; display: none;} .animateSlideImgBox .text1 {font-family: Microsoft YaHei; font-size: 36px; line-height: 1.2em; color: #384cd0; position: absolute; top: 120px; z-index: 3; white-space: Nowrap;} .animateSlideImgBox .text2 {font-family: Microsoft YaHei; font-size: 26px; line-height: 1.2em; color: orange; position: absolute; top: 200px; z-index: 3; white-space: Nowrap;} .animateSlideImgBox .img {position: absolute; left: 470px; top: 0; z-index: 2;} .animateSlideBtnL,.animateSlideBtnR { width: 30px; height: 60px; line-height: 60px; font-size: 20px; font-weight: 700; text-align: center; background: #ddd; position: absolute; left: 30px; top: 150px; z-index: 6; cursor: pointer; display: none; } .animateSlideBtnR {left: auto; right: 20px;}

jquery代码如下:

= size) { index = 0; } _imgBoxNext = _imgBox.eq(index); _nextText1 = _imgBoxNext.find(".text1"); _nextText2 = _imgBoxNext.find(".text2"); _nextImg = _imgBoxNext.find(".img"); _imgBox.find(".text1,.text2,.img").css("left",widthWin); _imgBoxCur.find(".text1,.text2").css("left",(widthWin - 980) / 2 + "px"); _imgBoxCur.find(".img").css("left",(widthWin - 980) / 2 + 470 + "px"); _btnR.on("click",function() { animateSlideFn(); }); _btnL.on("click",function() { animateSlideFn(); }); start = setTimeout(function() { animateSlideFn(); start = setTimeout(arguments.callee,opts.delayTime); },opts.delayTime); function animateSlideFn() { if(!(_imgBoxCur.find(".text1,.img").is(":animated") || _imgBoxNext.find(".text1,.img").is(":animated"))) { //当前帧动画 _curText1.animate({ left: parseInt(_curText1.css("left")) + 100 },opts.animateTime * 0.6,function() { _curText1.animate({ left: "-510px" },opts.animateTime); }); setTimeout(function() { _curText2.animate({ left: parseInt(_curText2.css("left")) + 100 },function() { _curText2.animate({ left: "-510px" },opts.animateTime); }); },200); setTimeout(function() { _curImg.animate({ left: parseInt(_curImg.css("left")) + 200 },function() { _curImg.animate({ left: "-510px" },opts.animateTime,function() { _imgBox.find(".text1,widthWin); _imgBoxCur.removeClass("present"); }); }); },400); //下一帧动画 setTimeout(function() { _imgBoxNext.addClass("present"); _nextText1.animate({ left: (widthWin - 980) / 2 - 100 },function() { _nextText1.animate({ left: (widthWin - 980) / 2 },opts.animateTime * 0.6); }); setTimeout(function() { _nextText2.animate({ left: (widthWin - 980) / 2 - 100 },function() { _nextText2.animate({ left: (widthWin - 980) / 2 },opts.animateTime * 0.6); }); },200); setTimeout(function() { _nextImg.animate({ left: (widthWin - 980) / 2 + 370 },function() { _nextImg.animate({ left: (widthWin - 980) / 2 + 470 },function() { index++; if(index >= size) { index = 0; } _imgBoxCur = _imgBox.filter(".present"); _imgBoxNext = _imgBox.eq(index); _curText1 = _imgBoxCur.find(".text1"); _curText2 = _imgBoxCur.find(".text2"); _curImg = _imgBoxCur.find(".img"); _nextText1 = _imgBoxNext.find(".text1"); _nextText2 = _imgBoxNext.find(".text2"); _nextImg = _imgBoxNext.find(".img"); }); }); },400); },opts.density * 1200); } } }); }; })(jQuery);

$(function() {
$(".animateSlide").animateSlide({
btnL: ".animateSlideBtnL",delayTime: 6000,density: 0.9
});
});

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐