多物体 链式运动
来源:互联网 发布:c语言基础知识大全 编辑:程序博客网 时间:2024/04/30 14:25
<!DOCTYPE html><html><head><title>NBodyMove test</title><style type="text/css">*{margin:20px 0px 0px;padding :0px;}li{width: 200px;height: 100px;background-color: red;list-style-type: none;border: 4px solid #000;filter: alpha(opacity:30);opacity: 0.3;}</style><script type="text/javascript">window.onload=function(){var list=document.getElementsByTagName('li'); // list.onmouseover=function(){ // startmove(list,'width',400,function(){ // startmove(list,'height',200);// }); // }for(var i=0;i<list.length;i++){//list[i].alpha=30;//控制每个li的初始透明度list[i].timer=null;list[i].onmouseover=function(){var that=this;//注意,要在回调函数中用别的,用this不管用startmove(this,'width',400,function(){startmove(that,'height',200);});}list[i].onmouseout=function(){var that=this;startmove(this,'width',200,function(){startmove(that,'height',100);});}} }//var alpha=30;一般不会用公共的变量//var timer=null;function startmove(obj,attr,iTarget,fn){clearInterval(obj.timer);obj.timer=setInterval(function(){//判断改变值var icur=0;if(attr=='opacity'){icur=Math.round(parseFloat(getStyle(obj,attr))*100);//float出来的是小于1的小数,所以*100//Math.round去1.00055555的尾巴}else{icur=parseInt(getStyle(obj,attr));}//计算速度var speed=(iTarget-icur)/10; speed=speed>0?Math.ceil(speed):Math.floor(speed); //运动 if(icur ==iTarget){ clearInterval(obj.timer); if(fn){ fn(); } } else{ if(attr=='opacity'){ obj.style.filter='alpha(opacity'+(icur+speed)+')';//IE obj.style.opacity=(icur+speed)/100; } else{ obj.style[attr]=icur+speed+'px'; } }},30);}function getStyle(obj,attr){if(obj.currentStyle){return obj.currentStyle[attr];//IE浏览器}else{return getComputedStyle(obj,false)[attr];//针对火狐浏览器}}</script></head><body><ul><li></li><li></li></ul></body></html>
0 0
- 多物体 链式运动
- 多物体 链式运动
- 多个物体 链式运动
- js物体链式运动
- js运动-多物体运动
- 多物体运动
- 多物体运动
- JS多物体运动
- 多物体运动
- 多物体运动
- 多物体运动框架
- 多物体运动
- 【HTML】多物体运动
- javascript运动框架多物体运动---1
- javascript运动框架多物体运动---1
- js运动技术--多物体同时运动
- 多物体组合运动最终版
- js多物体不同运动
- myeclipse更改某种后缀文件的打开方式
- setNeedsDisplay、setNeedsLayout
- JDBC 连接 hive2 遇到的java.lang.ClassNotFoundException: org.apache.hive.jdbc.HiveDriver
- 人物列传
- Qt之图形视图框架
- 多物体 链式运动
- GIT提交代码到远程创库
- Codeforces Round #363 (Div. 2) C. Vacations(逻辑运算)
- HDOJ1222--Wolf and Rabbit
- 创业之动漫社创立分析
- 隐藏你的 Linux 的命令行历史
- 合唱队----动态规划(求解最大递增/减子序列)
- Spring Data JPA
- swift 移动支付之【支付宝支付】详细步骤