web动画的方式 aa3e requestAnimationFrame
2016-05-19 14:24
393 查看
转载:http://www.cnblogs.com/Wayou/p/requestAnimationFrame.html
在性能上,
在性能上,
requestAnimationFrame > setTimeout > setInterval。具体原因大家可以找找相关的资料了解一下。而
setTimeout的最小定时值为
100/60
我们在实现运动时,从性能与兼容性两方面考虑,常常会如下声明:
var lastTime = 0, nextFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.msRequestAnimationFrame || function(callback) { var currTime = + new Date, delay = Math.max(1000/60, 1000/60 - (currTime - lastTime)); lastTime = currTime + delay; return setTimeout(callback, delay); }, cancelFrame = window.cancelAnimationFrame || window.webkitCancelAnimationFrame || window.webkitCancelRequestAnimationFrame || window.mozCancelRequestAnimationFrame || window.msCancelRequestAnimationFrame || clearTimeout;
相关文章推荐
- maven build脚本笔记
- 关于iOS中的弹出窗口----UIAlertController
- UUID
- 解决ADT大量出现"Unexpected value from nativeGetEnabledTags: 0"的问提
- iOS学习之——UIButton
- 使用Hibernate SQLQuery执行原生SQL
- Quickly Search Articles in My Blog - 快速搜索本专栏内的文章
- UIColor+Hex
- UITableView的属性和方法
- easyui datagrid使用updateRow更改单元格值后getChanges无法获取
- UISegmentedControl 功能简单 分析
- Android Studio 解决 finished with non zero exit value
- UILabel指定区域变颜色,UILabel指定数字变颜色
- STL之priority_queue(优先队列)
- Execution failed for task ':xxxx:lint'. > Lint found errors in the project; aborting build.
- UITableView:改变 TableHeaderView 的高度
- STL容器总结之stack和queue
- STL容器总结之deque
- Android进阶之自定义View实战(一)仿iOS UISwitch控件实现
- Java-GUI-JTextArea/JTextField/JTextPane