'use strict';
function getStyle(obj,sName){
return (obj.currentStyle||getComputedStyle(obj,false))[sName];
}
//function move(obj,json,time,type,fn)
function move(obj,json,options){
options=options||{};
options.time=options.time||700;
options.type=options.type||'linear';
var start={};
var dis={};
for(var name in json){
start[name]=parseInt(getStyle(obj,name));
if(isNaN(start[name])){
//加默认值
switch(name){
case 'left':
start[name]=obj.offsetLeft;
break;
case'top':
start[name]=obj.offsetTop;
break;
case'width':
start[name]=obj.offsetWidth;
break;
case'Height':
start[name]=obj.offsetHeight;
break
case'opacity':
start[name]=1;
break;
case'border':
start[name]=0;
}
}
dis[name]=json[name]-start[name];
}
var count=Math.floor(options.time/30);
var n=0;
clearInterval(obj.timer);
obj.timer=setInterval(function(){
n++;
var ocr='';
for(var name in json){ switch(options.type){
case'linear':
var a=n/count;
ocr=start[name]+a*dis[name];
break;
case'ease-in':
var a=n/count;
ocr=start[name]+Math.pow(a,3)*dis[name];
break;
case'ease-out':
var a=(1-n/count);
ocr=start[name]+(1-Math.pow(a,3))*dis[name];
break;
}
if(name=='opacity'){
obj.style[name]=ocr;
obj.style[name]='filter:alpha(opacity='+ocr*100+')';
}else{
obj.style[name]=ocr+'px';
}
}
if(n==count){
clearInterval(obj.timer);
options.end&&options.end();
}
},30);
}

最新文章

  1. mac包管理器Homebrew安装命令
  2. Centos7下安装python,查看python版本
  3. .NET Attributes
  4. Oracle AWR 数据导入/导出的步骤
  5. 7zip ubuntu使用
  6. 如何实现phpcms v9_4X版本tag的伪静态?
  7. IOS项目集成ShareSDK实现第三方登录、分享、关注等功能(备用)
  8. struts2操作pojo之小工程struts2ActionPOJO
  9. Geodatabase - 打开数据库(工作空间)
  10. Web安全技术(3)-浏览器的跨域访问
  11. CSS学习笔记二:css 画立体图形
  12. Netty开发redis客户端,Netty发送redis命令,netty解析redis消息
  13. leetcode数据库题目及答案汇总
  14. k8s初始化搭建方法
  15. CNZZ友盟访问明细的采集办法
  16. Android手机上浏览器不支持带端口号wss解决方案
  17. Oracle用户密码认证方式
  18. servet概述
  19. 6、JVM--类文件结构(上)
  20. Hbase 学习(六) 配置文件调优

热门文章

  1. vs2008快捷键极其技巧
  2. Spring AOP详解(转载)
  3. C# 调用Delphi dll
  4. rpm包的安装,查询,卸载,升级,校验,数据库重建,验证数据包
  5. [Cocos2d-x for WP8学习笔记] 获取系统字体
  6. 【Asp.net MVC】AJAXHelper 和jQueryAjax
  7. Codeforces Gym 100513F F. Ilya Muromets 水题
  8. canvas绘制五角星详细过程
  9. eclipse的classpath(build path)和classpaht几种设置的方式
  10. delphi 10.2 ----简单的递归函数例子求和