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('绑定方式一') }); // 绑定方 ...
随机推荐
- MapReduce-寻找三角形
在图中,如何判断三角形?三角形在很多场景都有应用,比如社交网络中确定人和人之间的关系. 那么如果通过代码逻辑来实现呢?在数据结构之图中,区分三联体(有一端没有关联关系的三角形)和三角形是关键:两者之间 ...
- POJ3585 Accumulation Degree(二次扫描与换根法)
题目:http://poj.org/problem?id=3585 很容易想出暴力.那么就先扫一遍. 然后得到了指定一个根后每个点的子树值. 怎么转化利用一下呢?要是能找出当前点的父亲的 “ 不含当前 ...
- redis和memcached选择,对比分析
memcache和redis是互联网分层架构中,最常用的KV缓存.不少同学在选型的时候会纠结,到底是选择memcache还是redis? memcache提供的功能是redis提供的功能的子集,不用想 ...
- UDP丢包问题
1. 问题描述 PC-A向PC-B发送UDP packet(共16K bytes),如果B机木有及时Read,UDP包将大量丢失. 2. 原因及解决 因为B木有及时接收,socket缓冲区放不下了. ...
- NoSQL非结构化数据库高级培训课程-大纲
一.课程概述 本课程面向No-SQL开发人员.系统分析和系统架构师,目的在于帮助他们建立起完整的No-SQL数据库的概念,应用场景.相关开源技术框架和优缺点. 二.课程大纲 主题 时间 主题 No-S ...
- 解决Qt Creator下 undefined reference to 'qmain(int,char**)'的问题
Qt Creator运行以下程序: #include <QTextStream> #include <QList> int main(void) { QTextStream o ...
- 2018-2019 20165226 Exp6 信息搜集与漏洞扫描
2018-2019 20165226 Exp6 信息搜集与漏洞扫描 目录 一.实验内容说明及基础问题回答 二.实验过程 Task1 各种搜索技巧的应用 检测特定类型的文件 搜索网址目录结构 trace ...
- python random 随机选择操作
# -*- coding:utf-8 -*- import random arr = ['A','B','C','D','E','F'] #生成(0.0, 1.0)的随机数 print random. ...
- centos7开机界面出现多个选项
第一个选项正常启动,第二个选项急救模式启动(系统出项问题不能正常启动时使用并修复系统) 在CentOS更新后,并不会自动删除旧内核.所以在启动选项中会有多个内核选项,可以手动使用以下命令删除多余的内核 ...
- 1009 Product of Polynomials (25 分)
1009 Product of Polynomials (25 分) This time, you are supposed to find A×B where A and B are two pol ...