js实现jquery函数animate动画效果
<script>
function animate(obj, json, interval, sp, fn) {
clearInterval(obj.timer);
function getStyle(obj, arr) {
if(obj.currentStyle){
return obj.currentStyle[arr]; //针对ie
} else {
return document.defaultView.getComputedStyle(obj, null)[arr];
}
}
/* function getStyle(dom, pro) {
if (window.getComputedStyle) {
return window.getComputedStyle(dom, null)[pro]
} else {
if (dom.currentStyle) {
return dom.currentStyle[pro]
} else {
return dom.style[pro]
}
}
}*/
obj.timer = setInterval(function(){
var flag = true;
for(var arr in json) {
var icur = 0;
if(arr == "opacity") {
icur = Math.round(parseFloat(getStyle(obj, arr))*100);
} else {
icur = parseInt(getStyle(obj, arr));
}
var speed = (json[arr] - icur) * sp;
speed = speed > 0 ? Math.ceil(speed): Math.floor(speed);
if(icur != json[arr]){
flag = false;
}
if(arr == "opacity"){
obj.style.filter = "alpha(opacity : '+(icur + speed)+' )";
obj.style.opacity = (icur + speed)/100;
}else {
obj.style[arr] = icur + speed + "px";
}
//console.log(j + "," + arr +":"+ flag);
}
if(flag){
clearInterval(obj.timer);
//console.log(j + ":" + flag);
//console.log("k = " + k);
//console.log("j = " + j);
//console.log("DONE");
if(fn){ fn(); }
}
},interval);
}
</script>
<ul id="move" style="list-style:none;font-family:'Arial';color:White">
<li style="width:200;height:60;background-color:red">AAAAA</li>
<li style="width:200;height:60;background-color:blue">BBBBB</li>
<li style="width:200;height:60;background-color:Navy">CCCCCC</li>
<li style="width:200;height:60;background-color:green">DDDDDD</li>
<li style="width:200;height:60;background-color:pink">EEEEE</li>
</ul>
<script>
var move = document.getElementById("move").getElementsByTagName("li");
for(var i = 0; i < move.length; i ++){
move[i].onmouseover = function(){
var _this = this;
animate(_this, {width: 500, height: 60},10, 0.1, function(){
// animate(_this, {width: 200, height: 100},10, 0.1);
});
}
move[i].onmouseout = function(){
animate(this, {width: 200, height: 60},10, 0.1);
}
}
</script>
js实现jquery函数animate动画效果的更多相关文章
- jquery animate 动画效果使用解析
animate的意思是:使有生气:驱动:使栩栩如生地动作:赋予…以生命作为形容词:有生命的:活的:有生气的:生气勃勃的 先看动画效果:http://keleyi.com/keleyi/phtml/jq ...
- jquery的animate({})动画整理
在网页制作的过程中少不了用到各种动画,形式多种多样,flash,css,js,canvas,等等都能实现,对于其优劣和效果只能说各有千秋. 什么是动画效果,其实网页中的渐变效果就是一种很基础的动画,动 ...
- Jquery如何使用动画效果改变背景色
Jquery如何使用动画效果改变背景色 一.问题引入 jquery的animate动画虽然强大,但是无法使用其进行背景色(background-color)的动画效果变化,因为animate动画效果只 ...
- jQuery中animate动画第二次点击事件没反应
jQuery中animate动画第二次点击事件没反应 用animate做点击翻页动画时发现第二次点击事件动画没反应,而第一次点击有动画效果,代码如下: 复制代码 代码如下: $(".page ...
- 使用two.js生成的卫星环绕动画效果
来源:GBin1.com two.js是一个帮助你实现绘图和动画效果的类库,同时支持三种前端绘图实现: webgl svg 2d画布 使用这个类库,可以方便的支持这三种不同的实现,你只需要设置参数:T ...
- jQuery animate()动画效果
1.jQuery动画效果 jQuery animate()方法用于创建自定义动画 $(selector).animate({params},speed,callback); //必需的 params ...
- JQuery(二)——简单动画效果
上一篇博客总结了JQuery的一些基本知识,这篇博客重点从JQuery能够制造各种各样的网页效果方面来进行总结.总结一些常见的常用的基本效果的必备方法.从隐藏显示,淡入淡出,滑动,动画等几个方面来简单 ...
- jQuery的事件,动画效果等
一.事件 click(function(){}) 点击事件 hover(function(){}) 悬浮事件,这是jQuery封装的,js没有不能绑定事件 focus(function(){}) ...
- python 之 前端开发( jQuery事件、动画效果、.each()、 .data())
11.58 事件 11.581 事件绑定方法与解绑 绑定事件: // 绑定方式一: $('.box1').click(function () { alert('绑定方式一') }); // 绑定方 ...
随机推荐
- 洛谷 4389 付公主的背包——多项式求ln、exp
题目:https://www.luogu.org/problemnew/show/P4389 关于泰勒展开: https://blog.csdn.net/SoHardToNamed/article/d ...
- PHP错误和异常处理
1.错误报告级别: 错误E_ERROR; 警告 E_WARNING 注意 E_NOTICE 2.php.ini 中的配置 error_reporting=; 错误提示 一般设置为: error_re ...
- qt 中文乱码
首先呢,声明一下,QString 是不存在中文支持问题的,很多人遇到问题,并不是本身 QString 的问题,而是没有将自己希望的字符串正确赋给QString. 很简单的问题,"我是中文&q ...
- 关于 android 返回键 代码实现
转自:http://www.dewen.io/q/11313/android+%E6%A8%A1%E6%8B%9F%E8%BF%94%E5%9B%9E%E9%94%AE%E5%8A%9F%E8%83% ...
- 阿里云服务器挖矿wipefs处理
查看指定日志修改过的文件: [root@iZbp12v0moqn078lm0t0l5Z 2018-04-26]# find /data/www/manage -ctime 0 -exec ls -l ...
- 使用pip安装Scrapy出错
目录 安装Scrapy出错 安装 使用pip安装(Ubuntu) 错误信息 解决方法 安装Scrapy出错 安装 使用pip安装(Ubuntu) # 安装pip sudo apt install py ...
- maven学习(1)-简介与安装
一.Maven 简介 Maven 官网:http://maven.apache.org/ 二.Maven 安装与配置 Maven 下载:http://maven.apache.org/download ...
- Java-Web中访问某个指定工程中的文件,报错后发现访问的文件是另一个工程里面的文件
问题: 浏览器向我的bingou项目中的UserDaoImpl.java发送请求, myeclipse报错:空指针异常 点击报错行之后,错误给定位到了另一个项目中的的一个文件 解决: 原因是文件名错误 ...
- centos svn 的搭建
一. SVN 简介 Subversion(SVN) 是一个开源的版本控制系統, 也就是说 Subversion 管理着随时间改变的数据. 这些数据放置在一个中央资料档案库(repository) 中. ...
- JedisCluster中应用的Apache Commons Pool对象池技术
对象池技术在服务器开发上应用广泛.在各种对象池的实现中,尤其以数据库的连接池最为明显,可以说是每个服务器必须实现的部分. apache common pool 官方文档可以参考:https://c ...