animation
动画,一帧一帧地播放静态页面。
在前端领域无非两种方式实现:
- JavaScript用DOM API的setInterval函数实现
- 用CSS3的transition、animation属性实现
setInterval方式
1 2 3 4 5 6 7 8 9
| function animate(element) { clearInterval(element.timeId); element.timeId = setInterval(function () { todoing() } }, 10); }
|
CSS transition animation
1 2 3 4
| transition: property duration curve delay; <!-- 事件、伪类触发,element property的变化,transition自动脑补 --> transform: translate(x, y) || scale(x, y) || rotate(180deg) || skew(180deg, deg); <!-- 同时transform也可以操控3d,x左负右正;y上负下正;z里负外正 -->
|
1 2 3 4 5 6 7
| animation: name duration curve delay count direction; @keyframes name { 0%{} 50%{} 100%{} }
|