Animation简单效果
来源:互联网 发布:有思度软件 编辑:程序博客网 时间:2024/06/10 17:19
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Animation简单效果</title></head><body> <div style="position:absolute;background:blue" id="div">我是div</div></body><script> var tween = { linear:function(t,b,c,d){ return c*t/d +b; }, easeIn:function(t,b,c,d){ return c*(t /= d)*t+b; }, strongEaseIn:function(t,b,c,d){ return c*(t /= d)*t*t*t*t+b; }, strongEastOut:function(t,b,c,d){ return c*((t = t / d - 1)*t * t * t * t + 1) + b; }, sineaseIn:function(t,b,c,d){ return c * ( t /= d) * t * t + b; }, sineaseOut:function(t,b,c,d){ return c * ((t = t / d - 1) * t * t + 1) + b; } } var Animate = function(dom){ this.dom = dom;//进行运功的dom节点 this.startTime = 0; this.startPos = 0; this.endPos = 0; this.propertyName = null; this.easing = null; this.duration = null; } /* *要改变的属性名,比如left表示左右移动 *目标位置 *动画持续时间 *缓动算法 */ Animate.prototype.start = function(propertyName,endPos,duration,easing){ this.startTime = +new Date; this.startPos = this.dom.getBoundingClientRect()[propertyName]; this.propertyName = propertyName; this.endPos = endPos; this.duration = duration; this.easing = tween[easing]; var self = this; var timeId = setInterval(function(){ if(self.step() === false){ clearInterval(timeId); } },19) }; Animate.prototype.step = function(){ var t = +new Date; if(t >= this.startTime + this.duration){ this.update(this.endPos); return false; } var pos = this.easing(t - this.startTime,this.startPos,this.endPos - this.startPos,this.duration); this.update(pos); } Animate.prototype.update = function(pos){ this.dom.style[this.propertyName] = pos + 'px'; } var div = document.getElementById('div'); var animate = new Animate(div); animate.start('top',500,1000,'strongEastOut');</script></html>
0 0
- Animation简单效果
- Animation动画效果简单汇总
- animation效果
- android 初始绘画 view 以及调用Animation简单效果
- Android动画效果Animation之Tween实现简单动画
- 简单的animation动画效果的实现过程
- Android动画效果Animation之Tween实现简单动画
- css3的简单动画效果(animation和transition)
- 简单的数据可视化,并加入了animation动态效果
- Android 动画效果 --Animation
- Android 动画效果 --Animation
- Android 动画效果 --Animation
- Android Animation动画效果
- android Animation 动画效果
- ListView增加Animation效果
- 动画效果 --Animation 总汇
- Animation动画效果
- android Animation 动画效果
- 第十六周 项目1--验证算法(7)--归并排序
- 在安卓开发中调用手机相册,相机,选择相片裁剪并上传
- java获取当前类类名
- 基于 Token 的身份验证
- POJ_3299 Humidex(简单题)
- Animation简单效果
- css笔记:CSS显示图片中间区域
- 魔方阵
- HDU 5970 最大公约数
- 个人中使用caffe做回归中遇到的问题和解决办法
- 51nod-1093:骆驼和香蕉
- 约束满足问题的求解方法之基于回溯的搜索和基于相容性技术的约束传播
- Remove Duplicates from Sorted Array II
- 深入研究 Java Synchronize 和 Lock 的区别与用法