博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
变速动画函数封装增加任意一个属性
阅读量:7235 次
发布时间:2019-06-29

本文共 810 字,大约阅读时间需要 2 分钟。

//计算后的样式属性---- 一个元素的任意的一个样式属性值 function getStyle(element,attr) {
//判断这个浏览器是否支持这个方法 return window.getComputedStyle?window.getComputedStyle(element,null)[attr]:element.currentStyle[attr]; } //匀速动画 function animate(element,attr,target) { //element--元素 attr--属性名字 target--目标位置 //清理定时器 clearInterval(element.timeId); element.timeId=setInterval(function () {
//获取元素当前位置 var current=parseInt(getStyle(element,attr));//数字类型 //移动的步数 var step=(target-current)/10; step=step>0?Math.ceil(step):Math.floor(step); current+=step; element.style[attr]=current+"px"; if(current==target){
//清理计时器 clearInterval(element.timeId); }22 变速动画函数封装增加任意一个属性

转载于:https://www.cnblogs.com/lujieting/p/10055289.html

你可能感兴趣的文章
python什么时候使用多线程,什么时候使用多进程?
查看>>
Quartz中时间表达式的设置-----corn表达式 (转)(http://www.cnblogs.com/GarfieldTom/p/3746290.html)...
查看>>
Flash Media Server 5.0 (FMS)注册码
查看>>
根据匹配词个数排序
查看>>
Xcopy命令参数使用介绍
查看>>
Java ArrayList、Vector和LinkedList等的差别与用法(转)
查看>>
用flock命令解决Linux计划任务重复执行
查看>>
[再寄小读者之数学篇](2014-06-19 两个分部积分)
查看>>
Opencv cvCircle函数
查看>>
CMD命令 - yanghj - 博客园
查看>>
mysql 加入列,改动列,删除列。
查看>>
网格导入设置 Import settings for Meshes
查看>>
m2014-architecture-imgserver->Lighttpd +mod_mem_cache的效果简直太好了
查看>>
POSIX semaphore: sem_open, sem_close, sem_post, sem_wait
查看>>
wcf中的使用全双工通信(转)
查看>>
PowerDesigner生成Access数据库
查看>>
20140720感受
查看>>
Android平台调用Web Service:演示样例
查看>>
${ }的用法
查看>>
【JavaScript】 2013年度最强AngularJS资源合集
查看>>