全新jquery多点滑动幻灯片——全屏动画animateSlide
首页banner的酷炫效果多来自全屏大图的幻灯片动画,下面提供一种完美兼容的jquery动画特效:全新jquery多点滑动幻灯片——全屏动画animateSlide(代码完全原创)。
直接上代码,把html、css和jquery代码copy到页面上即可呈现完美画面。
html代码如下:
<div class="animateSlide">
<div class="animateSlideImgWrap">
<div class="animateSlideImgBox present">
<p class="text1">亲,这是第一行标题</p>
<p class="text2">AAAAAAAAAAAAAAAAAAAAA</p>
<!--<img class="img" alt="" src="img/1.png" />-->
<div class="img" style="width: 500px; height: 390px; background: #ffaeae; opacity: 0.6;"></div><!-- 实际项目中用上面注释的半透明png图片,目前临时用div代替图片 -->
</div>
<div class="animateSlideImgBox">
<p class="text1">亲,这是一行宣传语</p>
<p class="text2">BBBBBBBBBBBBBBBBBBBBB</p>
<!--<img class="img" alt="" src="img/2.png" />-->
<div class="img" style="width: 500px; height: 390px; background: #aeffb2; opacity: 0.6;"></div><!-- 实际项目中用上面注释的半透明png图片,目前临时用div代替图片 -->
</div>
<div class="animateSlideImgBox">
<p class="text1">亲,这是一个奇迹啊</p>
<p class="text2">CCCCCCCCCCCCCCCCCCCCC</p>
<!--<img class="img" alt="" src="img/3.png" />-->
<div class="img" style="width: 500px; height: 390px; background: #aebdff; opacity: 0.6;"></div><!-- 实际项目中用上面注释的半透明png图片,目前临时用div代替图片 -->
</div>
</div>
<div class="animateSlideBtnL"><</div>
<div class="animateSlideBtnR"><</div>
</div>
css代码如下:
.animateSlide {width: 100%; height: 390px; position: relative; background: #f5f5f5;}
.animateSlideImgWrap {width: 100%; height: 390px; position: absolute; z-index:; overflow: hidden;}
.animateSlideImgWrap .present {display: block;}
.animateSlideImgBox {width: 100%; height: 390px; position: absolute; z-index:; display: none;}
.animateSlideImgBox .text1 {font-family: Microsoft YaHei; font-size: 36px; line-height: 1.2em; color: #384cd0; position: absolute; top: 120px; z-index:; white-space: nowrap;}
.animateSlideImgBox .text2 {font-family: Microsoft YaHei; font-size: 26px; line-height: 1.2em; color: orange; position: absolute; top: 200px; z-index:; white-space: nowrap;}
.animateSlideImgBox .img {position: absolute; left: 470px; top:; z-index:;}
.animateSlideBtnL,
.animateSlideBtnR {
width: 30px; height: 60px; line-height: 60px; font-size: 20px; font-weight:; text-align: center; background: #ddd;
position: absolute; left: 30px; top: 150px; z-index:; cursor: pointer; display: none;
}
.animateSlideBtnR {left: auto; right: 20px;}
jquery代码如下:
(function($) {
$.fn.animateSlide = function(options) {
var defaults = {
btnL: ".animateSlideBtnL",
btnR: ".animateSlideBtnR",
imgBox: ".animateSlideImgBox",
animateTime: 500,
delayTime: 5000,
density: 1
};
var opts = $.extend(defaults, options);
var widthWin = $(window).width();
$(window).resize(function() {
widthWin = $(window).width();
});
//
this.on("mouseenter", function() {
$(this).find(".animateSlideBtnL, .animateSlideBtnR").stop().fadeIn(400);
}).on("mouseleave", function() {
$(this).find(".animateSlideBtnL, .animateSlideBtnR").stop().fadeOut(400);
});
return this.each(function() {
var _this = $(this);
var _btnL = _this.find(opts.btnL);
var _btnR = _this.find(opts.btnR);
var _imgBox = _this.find(opts.imgBox);
var _imgBoxCur = _imgBox.filter(".present");
var _curText1 = _imgBoxCur.find(".text1"), _curText2 = _imgBoxCur.find(".text2"), _curImg = _imgBoxCur.find(".img");
var _imgBoxNext = null, _nextText1 = null, _nextText2 = null, _nextImg = null;
var index = _imgBox.index(_imgBoxCur) || 0;
var size = _imgBox.size();
var start = null;
index++;
if(index >= 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, .text2, .img").is(":animated") || _imgBoxNext.find(".text1, .text2, .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
}, opts.animateTime * 0.6, function() {
_curText2.animate({
left: "-510px"
}, opts.animateTime);
});
}, 200);
setTimeout(function() {
_curImg.animate({
left: parseInt(_curImg.css("left")) + 200
}, opts.animateTime * 0.6, function() {
_curImg.animate({
left: "-510px"
}, opts.animateTime, function() {
_imgBox.find(".text1, .text2, .img").css("left", widthWin);
_imgBoxCur.removeClass("present");
});
});
}, 400);
//下一帧动画
setTimeout(function() {
_imgBoxNext.addClass("present");
_nextText1.animate({
left: (widthWin - 980) / 2 - 100
}, opts.animateTime, function() {
_nextText1.animate({
left: (widthWin - 980) / 2
}, opts.animateTime * 0.6);
});
setTimeout(function() {
_nextText2.animate({
left: (widthWin - 980) / 2 - 100
}, opts.animateTime, function() {
_nextText2.animate({
left: (widthWin - 980) / 2
}, opts.animateTime * 0.6);
});
}, 200);
setTimeout(function() {
_nextImg.animate({
left: (widthWin - 980) / 2 + 370
}, opts.animateTime, function() {
_nextImg.animate({
left: (widthWin - 980) / 2 + 470
}, opts.animateTime * 0.6, 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",
btnR: ".animateSlideBtnR",
imgBox: ".animateSlideImgBox",
animateTime: 500,
delayTime: 6000,
density: 0.9
});
});
全新jquery多点滑动幻灯片——全屏动画animateSlide的更多相关文章
- 基于js全屏动画焦点图幻灯片
今天给大家分享一款基于js全屏动画焦点图幻灯片.这款焦点图内的内容以动画形式出现和消失.效果图如下: 在线预览 源码下载 实现的代码. html代码: <div class="sl ...
- JS框架_(JQuery.js)文章全屏动画切换
百度云盘 传送门 密码:anap 文章全屏动画切换效果 <!doctype html> <html lang="zh"> <head> < ...
- jQuery鼠标滚动垂直全屏切换代码
体验效果:http://hovertree.com/texiao/jquery/68/ 源码下载:http://hovertree.com/h/bjaf/f643upc4.htm 代码如下: < ...
- 如何给PDF设置全屏动画
PPT文件可以播放全屏,并且可以实现飞入.分割.闪烁等动画模式播放.那么PDF文件可以吗?我们想要给PDF文件加入动画效果应该怎么做呢,也有很多的小伙伴不知道该怎么把PDF文件切换为全屏动画模式想要知 ...
- 基于jQuery带进度条全屏图片轮播代码
基于jQuery带进度条全屏图片轮播代码.这是一款基于jQuery实现的oppo手机官网首页带进度条全屏图片轮播特效.效果图如下: 在线预览 源码下载 实现的代码. html代码: <div ...
- ios滑动手势全屏(这段代码实现了下一级控制器滑到上一级控制器)
在自定义导航控制器里面加以下代码就增加全屏滑动手势 >推向前一个控制器 // HBNavigationController.m // #import "HBNavigationCon ...
- MyEclipse9中的不伤眼修改、FreeMarker插件、JQuery提示插件、全屏(FullScreen)插件的安装
============下载相关附件===================== http://files.cnblogs.com/fhtwins/eclipse-fullscreen_1.0.7.zi ...
- jQuery支持mobile的全屏水平横向翻页效果
这是一款支持移动手机mobile设备的jQuery全屏水平横向翻页效果插件. 该翻页插件能够使页面在水平方向上左右全屏翻动,它支持手机触摸屏,支持使用鼠标滚动页面. 整个页面过渡平滑,效果很不错. 在 ...
- JQuery之滑动幻灯片插件Easy Slider初体验
Easy Slider 是一个滑动幻灯片插件,支持任何图片或内容,可以实现横向或纵向滑动.它拥有一系列丰富的参数设置,可通过CSS来进行完全的控制.基本上只需要引入这个插件后,设置好内容,然后样式化C ...
随机推荐
- Mac下cocos2dx-3.0打包Android时,提示"SimpleAudioEngine.h"not found的解决方法
前段时间触控公布cocos2dx-3.0,在升级之后试过之后,在最初的不习惯之后,感觉比之前的好用了不少,在下之前一直是用xCode模板创建,这回算是一口气升到顶了. 之后再一次编程时须要用到Sima ...
- Jquery Mobile 百度地图 Demo
首先非常感谢franck分享的Demo! Demo截图: 下面是franck对此Demo的说明: 原理:1.通过百度拾取坐标系统获得点位的坐标. http://api.map.baidu.com/lb ...
- VS2010中文/vs2008英文版/vs2005下载地址
ed2k://|file|cn_visual_studio_2010_ultimate_x86_dvd_532347.iso|2685982720|4AE6228933DDE49D9BFA4C3467 ...
- Objective-C面向对象的编程
Objective-C面向对象的编程 目录 对面向对象编程思想的理解 类的声明和定义 类的声明和定义 对关键字super和self的理解 初始化函数 @property声明类成员 类的实例化 继承 组 ...
- 好记心不如烂笔头之JQuery学习,第三章
第三章中主要讲了几个对DOM进行操作的方法. 归纳如下: 属性的获取和设置: //属性的获取 $("li").attr("title"); //属性的设置 $( ...
- linux下网络编程常见问题
网络程序异常退出无core文件产生 这种情况发生在一边连接端已经关闭,但是另外一边还在对连接句柄做send操作,这样做send操作的进程会收到SIGPIPE信号,默认行为是直接退出且不会产生core. ...
- stm32出现错误“identifier file is undefined”
为什么记录这个问题,说来很简单,这已经是第二次犯这个小错误了. 出现了错误“identifier file is undefined”的解决方法;option->general options- ...
- python脚本初探---新手如何直接编写一个hello world模块即可执行的.py文件
废话不多说,就讲一下这个背景吧: 事情是这个样子的~ 本着好学的精神,咱就买了本书,学习python结果呢,发现python的教程都是一个样子滴,上来的第一个hello world 都是通过IDLE来 ...
- SPA初试-1
本篇内容是在上一次的基础上进行改进,对状态的定义进行了修改,一个状态的定义如下: function state(stateName, template, templateUrl) { this.sta ...
- tachyon 配置项
Tachyon 配置参数分为4类:Master,Worker, Common (Master and Worker), and User configurations. 环境变量配置文件在$TACHY ...